Skip to content

Instantly share code, notes, and snippets.

@ericrasch
Last active August 29, 2015 14:10
Show Gist options
  • Save ericrasch/70cea2371c53f5128737 to your computer and use it in GitHub Desktop.
Save ericrasch/70cea2371c53f5128737 to your computer and use it in GitHub Desktop.
Reduce Git/GitHub repo bloat size...

The following is what worked for me the best and easiest when trying to reduce the size of a GitHub repo. Download bfg.jar from this site: http://rtyley.github.io/bfg-repo-cleaner/ (discovered here: http://stackoverflow.com/a/15771042) Rename bfg.#####.jar to bfg.jar and put it in your root /github repo folder. Run the following commands:

git clone --mirror git@github.com:CMN/YourRepoName.com.git
ditto YourRepoName.com.git YourRepoName.com.backup.git
java -jar bfg.jar --strip-biggest-blobs 500 YourRepoName.com.git
cd YourRepoName.com.git
git reflog expire --expire=now --all
git gc --prune=now --aggressive
git push

You might want to check/double-check the size of the repo before you push it back, but this works. I added the ditto command which will create a backup of your .git repo so you not only can compare the filesize, but will have a backup of your repo in case something goes wrong. The repo I ran this on went from 500+megs to 117megs.

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