Skip to content

Instantly share code, notes, and snippets.

@JacobDorman
Last active March 26, 2016 07:19
Show Gist options
  • Save JacobDorman/71ca58dca34473db500e to your computer and use it in GitHub Desktop.
Save JacobDorman/71ca58dca34473db500e to your computer and use it in GitHub Desktop.

Tools

bfg

bfg-repo-cleaner/ 'nuff said

git-gc-cron gem

git-gc-cron

Scripts

Manual way to delete large files

~/bin/findbigfiles.sh - creates bigtosmall.txt ~/bin/git_find_big.sh ~/bin/remove-files-from-repo.sh

Find all git repo's and garbage collect

find . -name '*.git' -execdir sh -c 'cd {} && git gc' \;
find . -name '*.git' -execdir sh -c 'cd {} && git gc --aggressive --prune=now' \;
find . -name '*.git' -execdir sh -c 'cd {} && realpath . && echo && git gc --aggressive --prune=now && git fetch --all && git b -avv && echo '---------------------'  && echo ' \;

we need to go deeper ...

questions/1029969/why-is-my-git-repository-so-big questions/1284669/how-do-i-manage-large-art-assets-appropriately-in-dvcs BITBUCKET/Reduce+repository+size

why you shouldn't use git gc

http://metalinguist.wordpress.com/2007/12/06/the-woes-of-git-gc-aggressive-and-how-git-deltas-work/

linus says

So the equivalent of "git gc --aggressive" - but done properly - is to do (overnight) something like

git repack -a -d --depth=250 --window=250

where that depth thing is just about how deep the delta chains can be (make them longer for old history - it's worth the space overhead), and the window thing is about how big an object window we want each delta candidate to scan.

And here, you might well want to add the "-f" flag (which is the "drop all old deltas", since you now are actually trying to make sure that this one actually finds good candidates.

Links

http://stackoverflow.com/questions/11255802/after-deleting-a-binary-file-from-git-history-why-is-my-repository-still-large https://confluence.atlassian.com/display/BITBUCKET/Reduce+repository+size http://stevelorek.com/how-to-shrink-a-git-repository.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment