I tried looking for a good tutorial on reducing repo size, but found none. How do I reduce my repo size...it\'s about 10 MB, but the thing is Heroku only allows 50 MB and I\
Thanks for your replies. Here's what I did:
git gc
git gc --aggressive
git prune
That seemed to have done the trick. I started with around 10.5MB and now it's little more than 980KBs.
In my case, I pushed several big (> 100Mb) files and then proceeded to remove them. But they were still in the history of my repo, so I had to remove them from it as well.
What did the trick was:
bfg -b 100M # To remove all blobs from history, whose size is superior to 100Mb
git reflog expire --expire=now --all
git gc --prune=now --aggressive
Then, you need to push force on your branch:
git push origin <your_branch_name> --force
Note: bfg is a tool that can be installed on Linux and macOS using brew:
brew install bfg
git gc --aggressive is one way to force the prune process to take place (to be sure: git gc --aggressive --prune=now
). You have other commands to clean the repo too. Don't forget though, sometimes git gc
alone can increase the size of the repo!
It can be also used after a filter-branch
, to mark some directories to be removed from the history (with a further gain of space); see here. But that means nobody is pulling from your public repo. filter-branch can keep backup refs in .git/refs/original, so that directory can be cleaned too.
Finally, as mentioned in this comment and this question; cleaning the reflog can help:
git reflog expire --all --expire=now
git gc --prune=now --aggressive
An even more complete, and possibly dangerous, solution is to remove unused objects from a git repository