Squash some commits
So as your working on a branch its a v.good idea to commit often to keep track of what you have done, but before you push to master you may well want to clean things up and squash some commits.
git rebase -i HEAD~5
where 5 is the number of commits you want to squash, as its interactive you can reorder your commits, change the commit messages, squash some commits and keep others. Just make sure you have your editor setup properly.
Written by Ed
Related protips
6 Responses
git rebase -i master
This will show you all of the commits on your feature branch and allow you to pick and squash any of them.
@paulyoung awesome. Even better
@paulyoung one for the aliases
And in case you want to undo a rebase:
git reflog
git reset --hard <last_commit_before_rebase>
There is also git rebase --interactive --autosquash
: http://technosorcery.net/blog/2010/02/07/fun-with-the-upcoming-1-7-release-of-git-rebase---interactive---autosquash/
@eskimoblood Wow looks cool