threads / discuss / 13360

Best way to optimize a git repository?

Subject: Best way to optimize a git repository?

## tl;dr

2 messages between May 3, 2008 and May 3, 2008.

replies: 1people: 2as markdown or json

skillzero@gmail.com· May 3, 2008, 00:34 UTC · lore

I want to periodically optimize my repositories even if it takes a long time to run the command. Should I do 'git gc --aggressive', 'git repack -a -d', 'git prune', or some combination? The documentation implies that things like git gc will use git repack, but I'm sort of looking for the definitive answer of what I should run to fully optimize my repositories. These are relatively new repositories, all created with git 1.5.5.1.

I also read somewhere (but can't find now) that some of these commands shouldn't be run while other people might be accessing the repository. I want to run these commands on a server that multiple people clone and pull from and push to. Is that safe to do? I'm okay if clone, pull, or push fail during this time (although I'd prefer if they didn't fail), I just don't want to corrupt the repository.

Stephen R. van den Berg· May 3, 2008, 10:02 UTC · re: skillzero@gmail.com · lore

Re: Best way to optimize a git repository?

skillzero@gmail.com wrote:
>I want to periodically optimize my repositories even if it takes a
>long time to run the command. Should I do 'git gc --aggressive', 'git
>I also read somewhere (but can't find now) that some of these commands
>shouldn't be run while other people might be accessing the repository.
Caveat emptor, indeed.
I have in my /etc/gitconfig the following:
[repack]
   UseDeltaBaseOffset = true
[pack]
   compression = 9
[alias]
   packall = !rm -rf .git/ORIG_HEAD .git/FETCH_HEAD .git/index .git/logs .git/info/refs .git/objects/pack/pack-*.keep .git/refs/original .git/refs/patches .git/patches && git prune --expire now && git repack -a -d --window=200 && git gc

A subsequent "git packall" does the trick, but this is best done on an otherwise idle repository.

-- 
Sincerely,                                                          srb@cuci.nl
           Stephen R. van den Berg.
"What do I do when I see someone *extremely gorgeous*?
 I stare, I smile, and when I get tired... I put the mirror down."

← back to recent threads