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

`git gc` fails with `fatal: gc is already running on machine 'ci-runner-3' pid 4242 (use --force if not)`.

IntermediateTroubleshootingRepository Health, Size and Performance
Answer

Likely causes → A .git/gc.pid lock file exists. Either another gc really is running, or a previous gc was killed (container stopped, host rebooted) and left the file behind.

Diagnose →

cat .git/gc.pid
ps -p 4242 -o pid,cmd       # only meaningful on the same host

Fix → If no gc process is running, remove the stale file or force it:

rm -f .git/gc.pid
git gc            # or: git gc --force

Prevent → Avoid running gc in parallel jobs that share a workspace; disable auto-gc on runners (gc.auto=0) and run maintenance in one scheduled job.

All Git & GitHub questions Roadmap: Git & GitHub

More on Repository Health, Size and Performance