In this article, we will learn how to combine multiple commits into a single commit right within the Azure DevOps portal without writing any git commands.
When multiple team members are contributing towards development of the code, one of the git best practices is to maintain the branch (of main/master) history as clean as possible. The clean history helps everyone understand the sequence of changes done by different team members.
At times, when developers work on their stories in their feature branches, it’s a common practice that they do multiple commits and when they are done with the development of the story, they merge their feature branch into main/master using the Pull Request as described in our Azure DevOps – Tips and Tricks – 13 – How to merge two branches using Pull Request approval workflow tip.
In this article, we are going to learn how to combine multiple commits done in the Feature branch into a single commit while completing the PR to maintain a clean history of the main/master branch.
Create a feature branch and perform some commits. In this example, I’m going to make four commits in the feature branch. However, while merging into main branch, it makes sense to push the changes as one single commit to maintain the history clean.
Once the above changes are done, raise a Pull Request described in our Azure DevOps – Tips and Tricks – 13 – How to merge two branches using Pull Request approval workflow tip, get it approved and while completing the Pull Request, ensure that you select Squash Commit in the Merge Type dropdown as shown in the below screenshot and then click on the Complete button.
Now, let’s review the history of the main branch as shown below where we have only one commit
We can also see all the four changes in the main branch within the single combined commit as shown below.
That’s is how we can do a squash merge right within the browser without running git commands.
In this article, we have learned how to combine multiple changes done with multiple commits without running any git commands.
Do you like this article? If you want to get more updates about these kind of articles, you can join my Learning Groups