I’ve seen git gc --aggressive --prune and git repack -a -d --depth=250 --window=250 recommended for reducing the size of your local .git folders where a long local history is not needed.
From my reading it seems git-repack is preferred, can anyone comment on this?
What I really want to know is how to decide on values for depth and window. I use git to commit, push, pull and merge, I have no idea what a delta chain or object window is.
“Object window” – when repacking
gitcompares each object (every version of every file, every directory tree object, every commit message, every tag…) against a certain number of other similar-ish objects to find one that creates the smallest delta – roughly speaking, the smallest patch that can create this object from that base object.“Delta chain” – When, in order to re-create object A, you first have to check out object B and apply a delta to it, but in order to create B you need object C, which requires D ….
Up to a point, increasing both
depthandwindowcan give you smaller packs. However, there are tradeoffs. Forwindow, a higher setting means thatgit repackwill compare each object with more objects while it is running, resulting in (potentially significantly) longer running time forgit repack. However, once the pack is generated,windowhas no effect on further operations (outside of otherrepacks, anyway).depth, on the other hand, has less impact on the run time ofgit repackitself (although it still affects it somewhat), but the deeper your delta trees get, the longer it takes to re-build an old object from the sequence of base objects required to create the file. That means longer times for things likecheckoutwhen you’re referencing older commits, so it can have a significant impact on the perceived efficiency ofgitif you do a lot of digging through your history. And, sincegitdoesn’t create deltas only against older objects, you can on occasion find a recent object that is slow to extract because it’s a number of levels down the tree – it’s not as common as with older objects, but it does happen.I personally use
window=1024anddepth=256on all my repos except for a couple of clones of very large projects (e.g. Linux kernel).