Squashing commits

git

Before opening a pull request squash commits in your feature branch to have a cleaner history. Here is how to squash the last 5 commits:

git reset --soft head~5
git commit -m 'my new commit message'

To squash all commits from commit ABC123 (inclusive) up to HEAD :

git reset --soft ABC123^ 
git commit -m 'my new commit message'

The first line moves HEAD to the parent of ABC123, but keeps all the changes from ABC123 through HEAD staged. If you have already pushed your branch you need to push force the new commit:

git push --force