I\'m experimenting with fairly aggressive auto gc in Git, mainly for packing purposes. In my repos if I do git config --list I have setup
...
gc
Note that gc auto is be more robust in Git 2.12.2 (released March 2017, two days ago).
See commit a831c06 (10 Feb 2017) by David Turner (csusbdt).
Helped-by: Jeff King (peff).
(Merged by Junio C Hamano -- gitster -- in commit d30ec1b, 21 Mar 2017)
gc: ignore oldgc.logfilesA server can end up in a state where there are lots of unreferenced loose objects (say, because many users are doing a bunch of rebasing and pushing their rebased branches).
Running "git gc --auto" in this state would cause agc.logfile to be created, preventing future auto gcs, causing pack files to pile up.
Since many git operations areO(n)in the number of pack files, this would lead to poor performance.Git should never get itself into a state where it refuses to do any maintenance, just because at some point some piece of the maintenance didn't make progress.
Teach Git to ignore
gc.logfiles which are older than (by default) one day old, which can be tweaked via thegc.logExpiryconfiguration variable.
That way, these pack files will get cleaned up, if necessary, at least once per day. And operators who find a need for more-frequent gcs can adjustgc.logExpiryto meet their needs.
Note: since Git 2.17 (Q2 2018), git gc --auto will run on each git commit too.
See "List of all commands that cause git gc --auto".
And there is a pre-gc --auto hook associated to that command too.