Skip to content

Instantly share code, notes, and snippets.

@JacobDorman
Created March 23, 2016 14:25
Show Gist options
  • Save JacobDorman/12e81ef169a58dbf94f7 to your computer and use it in GitHub Desktop.
Save JacobDorman/12e81ef169a58dbf94f7 to your computer and use it in GitHub Desktop.
# Tools
## bfg
[bfg-repo-cleaner/](http://rtyley.github.io/bfg-repo-cleaner/)
_'nuff said_
## git-gc-cron gem
[git-gc-cron](https://github.com/thomasritz/git-gc-cron)
# Scripts
## Manual way to delete large files
- http://naleid.com/blog/2012/01/17/finding-and-purging-big-files-from-git-history/
- https://stubbisms.wordpress.com/2009/07/10/git-script-to-show-largest-pack-objects-and-trim-your-waist-line/
~/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](http://stackoverflow.com/questions/1029969/why-is-my-git-repository-so-big)
[questions/1284669/how-do-i-manage-large-art-assets-appropriately-in-dvcs](http://stackoverflow.com/questions/1284669/how-do-i-manage-large-art-assets-appropriately-in-dvcs)
[BITBUCKET/Reduce+repository+size](https://confluence.atlassian.com/display/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