Git & Squash

I use Bitbucket & SourceTree as my preferred git solution.  I like the GUI for Sourcetree and Bitbucket lets me store multiple projects on their servers.  One thing I’ve run into is my git repositories getting too big.  This can happen for several reasons – the main one is I forget to copy my default .gitignore to a new project before initializing the repository, and then my Library folder along with lots of other useless files get included.

I’m also going to try and have less commits pushed to the server.  To that effect I’m using the interactive rebase option of Sourcetree.  This will let me make various commits during the day, and then before pushing to the server when I’m done, I’ll squash those commits into one.  That way I’ll merge all the changes and hopefully use less space.

I’m also looking into methods of removing files from the repository that I’ve accidentally added or that I later realize I don’t need and want to remove these files from all history, thus reducing the size of the repository.  I’ve been experimenting with “git filter-branch –tree-filter ‘rm <filename>’ HEAD” and “git filter-branch –index-filter ‘git rm –cached –ignore-unmatch <filename>’ HEAD” and seeing some success, but more experimentation is in order.

Leave a Reply