A long-lived CI workspace `.git` is 9.8 GiB, while a fresh clone of the same repo is 900 MiB.
IntermediateTroubleshootingRepository Health, Size and Performance
Answer
Likely causes → The cached workspace has accumulated every fetched PR ref (refs/remotes/pull/*), deleted branches that were never pruned, old tags, and loose objects from thousands of fetches. Auto-gc is often disabled on runners, so nothing is ever cleaned.
Diagnose →
git count-objects -vH
git for-each-ref | wc -l
git for-each-ref --format='%(refname)' | cut -d/ -f1-3 | sort | uniq -c | sort -rn | head
Fix →
git fetch --prune --prune-tags origin
git for-each-ref --format='%(refname)' refs/remotes/pull | xargs -r -n1 git update-ref -d
git reflog expire --expire=now --all
git gc --prune=now
Or simply delete the workspace and use a fresh shallow clone.
Prevent → Fetch only what the job needs (specific refspec, --depth), set fetch.prune=true, and schedule a weekly cleanup job on persistent runners.
More on Repository Health, Size and Performance
`git status` takes 8–15 seconds in a large monorepo.Intermediate`error: The last gc run reported the following. Please correct the root cause and remove .git/gc.log` followed by `warning: There are too many unreachable loose objects; run 'git prune' to remove them.`IntermediateEvery few commands Git prints `Auto packing the repository in background for optimum performance.` and the machine stutters.BeginnerA fresh clone downloads 4 GB, but the checked-out files are only 200 MB.Intermediate`git gc` or `git clone` dies with `fatal: Out of memory, malloc failed (tried to allocate 1073741824 bytes)` or `error: pack-objects died of signal 9`.Advanced`error: unable to create temporary file: No space left on device` followed by `fatal: failed to write object`.Beginner