I tried looking for a good tutorial on reducing repository size, but I found none. How do I reduce my repository size? It's about 10 MB, but Heroku only allows 50 MB and I'm nowhere near finished developing my application.
I added the usual suspects (log, vendor, doc, etc.) to the .gitignore file already. Although I only added .gitignore recently.
What can I do?
Update Feb. 2021, eleven years later: the new
git maintenancecommand (man page) should supersedegit gc, and can be scheduled.Original:
git gc --aggressiveis 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, sometimesgit gcalone 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-branchcan 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:
An even more complete, and possibly dangerous, solution is to remove unused objects from a git repository
Note that
git filter-reponow (Git 2.24+, Q4 2019) replaces the obsoletegit filter-branchor BFG: it is a python-based tool, to be installed first.Joe suggests: