diff --git a/containers/debian/base.Dockerfile b/containers/debian/base.Dockerfile
index 0c305537604976b2e89775b30780d8b9b799c9ef..9af02bcfab6f5ce852899b56af1eded0b3575b97 100644
--- a/containers/debian/base.Dockerfile
+++ b/containers/debian/base.Dockerfile
@@ -154,6 +154,7 @@ RUN <<EOF
 git config --global user.email "gitlab@eicweb.phy.anl.gov"
 git config --global user.name "EIC Container Build Service"
 git config --global advice.detachedHead false
+git config --global gc.autoDetach false
 git clone --filter=tree:0 https://github.com/${SPACK_ORGREPO}.git ${SPACK_ROOT}
 git -C ${SPACK_ROOT} checkout ${SPACK_VERSION}
 git -C ${SPACK_ROOT} gc --no-auto