I want to make a recommendation that every developer turn off automatic garbage collection in git. It's one of the first things I do setting up a new

git gc - You're not going to need it

submited by
Style Pass
2022-08-06 12:30:06

I want to make a recommendation that every developer turn off automatic garbage collection in git. It's one of the first things I do setting up a new machine.

Turn off garbage collection? Surely, I must be crazy, right? Automatic garbage collection is important, right, they wouldn't turn it on by default if it wasn't!? Not really.

Garbage collection for git in most every use case just isn't worth it. That is unless you're very regularly committing very large files, and then orphaning those commits. I don't see that happening in most uses cases; garbage just doesn't build up that quickly in normal usage.

I have been working with the same git repo every day for ten solid years with gc turned off. My .git folder is currently 554 MB whereas a fresh cloned copy is 112 MB. I could be saving a whole 442 MB - whoop de doo.

Turning off automatic gc means that anything you once committed will remain restorable, forever. Turning it off means if a rebase goes badly, you can always safely get back to the previous state of a now orphaned commit. There's zero chance of it ever disappearing.

Leave a Comment