Skip to content

Instantly share code, notes, and snippets.

@stevekm
Last active February 22, 2016 18:06
Show Gist options
  • Save stevekm/c8b2545bc867202499e9 to your computer and use it in GitHub Desktop.
Save stevekm/c8b2545bc867202499e9 to your computer and use it in GitHub Desktop.
How to remove large entries or files from git repository history and push the changes to update GitHub
First method (the hard way)
http://naleid.com/blog/2012/01/17/finding-and-purging-big-files-from-git-history
Second method (easier)
https://help.github.com/articles/removing-files-from-a-repository-s-history/
https://rtyley.github.io/bfg-repo-cleaner/
also see: http://stackoverflow.com/questions/2100907/how-to-remove-delete-a-large-file-from-commit-history-in-git-repository
- download the BFG program (wget http://repo1.maven.org/maven2/com/madgag/bfg/1.12.8/bfg-1.12.8.jar)
- pull down a new copy of the repo from GitHub (git clone)
- navigate to the repo, check its size (du -sh)
- make sure you have java runtime 1.7 or above loaded (module load java/1.7)
- from within the repo dir, run the bfg (java -jar ../bfg-1.12.8.jar --strip-blobs-bigger-than 20M .git)
- when its done, run the git command it gives you to finish cleaning up (git reflog expire --expire=now --all && git gc --prune=now --aggressive)
- if you are on a recent git version (module load git/2.6.5), then you can also do this too afterwards (git push origin --force)
- - that last one might not actually affect the GitHub repo size, who knows...
- according to the BFG author, you need to wait patiently now and hope that GitHub magically updates to fix the repo size (http://stackoverflow.com/a/25466952/5359531)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment