While working on a feature branch many times you come across a situation where you have to deliver a single commit from the feature branch to the master branch. But you have multiple commits for a single bug/feature in your feature branch.

Let’s say you have two branches masterand featureand their git commit history looks as below: To squash all the commits of your feature branch and merge them in the master branch, you can perform the following steps: git checkout master Now perform squash, this will take all your commits from the feature branch and creates one single squash for all commits of the feature branch into the master branch.

After performing all the above operations your git commit history will look as below: The master branch commit history will look as below after performing git merge --squash: That’s all for this article.

Related Articles