Seems like my project is getting bigger and bigger with every git commit/push. Is there a way to clean up my git folder?
I'm not sure what you want. First of all, of course each time you commit/push the directory is going to get a little larger, since it has to store each of those additional commits.
However, probably you want git gc
which will "cleanup unnecessary files and optimize the local repository" (man page).
Another possibly relevant command is git clean
which will remove untracked files from your tree (man page).
One scenario where your git repo will get seriously bigger with each commit is one where you are committing binary files that you generate regularly. Their storage won't be as efficient than text file.
Another is one where you have a huge number of files within one repo (which is a limit of git) instead of several subrepos (managed as submodules).
In this article on git space, AlBlue mentions:
Note that Git (and Hg, and other DVCSs) do suffer from a problem where (large) binaries are checked in, then deleted, as they'll still show up in the repository and take up space, even if they're not current.
If you have large binaries stored in your git repo, you may consider:
- managing those binaries in an external repository.
- manage your .git repo size
- try and remove those binaries from your history with
git filter-branch
(warning: this would rewrite the history, which is bad if you have already pushed your repo and if other have puled from it)