Interview Prep/Git & GitHub/Repository Health, Size and Performance

`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.`

IntermediateTroubleshootingRepository Health, Size and Performance
Answer

Likely causes → Background auto-gc ran, but thousands of unreachable loose objects are newer than gc.pruneExpire (2 weeks), so they cannot be pruned yet. Git writes the warning to .git/gc.log and skips auto-gc until you delete that file. Common after big rebases, filter-repo attempts or tools that create many temporary objects.

Diagnose →

cat .git/gc.log
git count-objects -vH       # "count" = loose objects, "size" = their size

Fix → If you do not need those unreachable objects (check git fsck --lost-found first if you lost work):

git prune --expire=now
git gc
rm -f .git/gc.log

Prevent → Use git maintenance start so housekeeping runs regularly, and avoid scripts that hash large amounts of throwaway content into the repo.

All Git & GitHub questions Roadmap: Git & GitHub

More on Repository Health, Size and Performance