Azure DevOps – Tips and Tricks – 14 –  How to combine multiple commits into a Single commit using squash merge

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.

Introduction

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.

Advertisements

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.

Advertisements

Feature 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.

Azure DevOps – Tips and Tricks – Combine multiple commits into one using squash merge – 4 commits

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.

Azure DevOps – Tips and Tricks – Combine multiple commits into one using squash merge – Squash merge
Advertisements

Now, let’s review the history of the main branch as shown below where we have only one commit

Azure DevOps – Tips and Tricks – Combine multiple commits into one using squash merge – main history

We can also see all the four changes in the main branch within the single combined commit as shown below.

Azure DevOps – Tips and Tricks – Combine multiple commits into one using squash merge – main changes

That’s is how we can do a squash merge right within the browser without running git commands.

Advertisements

Summary

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

WhatsApp

Telegram

Advertisements
Advertisements
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s