git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Hosting Git repositories: how useful will git-gc be?

From
Jeff King <peff@peff.net>
Date
Sep 5, 2009, 06:24 UTC
Message-ID
<20090905062424.GC29863@coredump.intra.peff.net>
In-Reply-To
<vpq1vmo9xai.fsf@bauges.imag.fr>
On Thu, Sep 03, 2009 at 11:45:25AM +0200, Matthieu Moy wrote:
> A question: is it necessary/recommanded/useless to set up a cron job
> doing a "git gc" in each repository? My understanding is that a push
> through ssh will do some packing, is it correct? Does receiving a pack
> trigger a "git gc --auto"?

The objects are transferred as a pack. If the number of objects is less than receive.unpackLimit (default 100), then they are unpacked to loose objects. If more, we keep the pack, after completing any missing deltas used by a thin pack.

So if you tend to push frequently, you will end up with a lot of loose objects. Even if you have packs, they will be larger than necessary because you will be missing deltas between objects across packs. And of course you will eventually end up with a large number of packs, which is less efficient (each pack has an index, but I believe we search the indices linearly).

Receiving a pack does not (AFAICT looking at the code) trigger a "gc --auto". Running it has other benefits, too, like pruning cruft and packing refs. So I think it is probably a good idea to run it periodically.

Running it daily or weekly is probably reasonable. You could run it on every push using the post-update hook, but that may cause excessive I/O for very little benefit.

-Peff
Previous: Matthieu Moy
Message 2 of 2 in “Hosting Git repositories: how useful will git-gc be?”
  1. Matthieu MoySep 3, 2009
  2. Jeff KingSep 5, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.