Matt Matt - 3 months ago 48
Git Question

Does git gc execute at deterministic intervals?

I've been reading up on git, and I have a very particular question I am struggling to answer.

When does

git gc
execute autonomously?

I've been hearing through the grape-vine of various forums that it occurs by default on a push or a fetch/pull - but I cannot find any source that verifies this. Even the documentation itself only gets this specific (emphasis mine):

Some git commands may automatically run git gc; see the --auto flag below for details

and the
flag specifies

Some git commands run git gc --auto after performing operations that could create many loose objects.

I want to be able to deterministically say:

"Loose tree and blob files will not have been cleaned up by git until one of the following commands is run: {mystery list here}. When running one of these commands, if the number of loose objects exceeds the value of
, git will automatically compress the objects into a packfile".


Currently those are:

  • fetch
  • merge
  • am
  • receive-pack

Actual list can be verified by doing a code search.

Also from that you can see that gc on receive can be disabled with receive.autogc, others just run the gc in the end.