In this article, I’m going to walk you through the professional standards of how to merge two branches in Azure DevOps. We won’t just look at the “buttons to click”; we will look at the architecture of a clean merge.
Table of Contents
How To Merge Two Branches In Azure DevOps
Here I will demonstrate the two primary ways to merge code: the Pull Request Method (the enterprise standard) and the Manual Command Line Method.
Method 1: The Pull Request (Recommended for Teams)
You should never merge directly into your protected branches. You use a Pull Request.
Log in to your Azure DevOps organization (e.g., dev.azure.com/YourCompany). Navigate to the project and select Repos from the left-hand sidebar, then click on Pull Requests. Check out the screenshot below for your reference.

Step 2: Initialize the Pull Request
Click the New Pull Request button. You will see two dropdown menus.
- Source Branch: This is your feature branch (e.g.,
users/john-doe/tax-calculator-update). - Target Branch: This is where the code is going (usually
mainordevelop).
Step 3: Documentation and Reviewers
Enter a descriptive title. Instead of “Fixing bug,” use “Fixed calculation error in New York State tax logic.” * Description: Use bullet points to explain what changed and why.
- Reviewers: Add your teammates. In many US firms, we require at least two approvals for production code.
- Work Items: Link the specific Azure Board task so stakeholders can track progress.
Step 4: The Review Phase
Your peers will review the code. They might leave comments or request changes. Azure DevOps allows for “threaded conversations,” making it easy to resolve disputes over code style or logic.
Step 5: Complete the Merge
Once the “Required” checks pass (Build Validation, Minimum Reviewers, Work Item Linking), click Complete.
You will be presented with Merge Types:
| Merge Type | What it Does | When to Use It |
| Basic Merge (No-FF) | Keeps all individual commits and creates a merge commit. | When you need a full, granular history. |
| Squash Merge | Condenses all commits into one single commit on the target branch. | Best Practice for keeping the Main history clean. |
| Rebase and Fast-Forward | Replays your commits on top of the target branch. | When you want a perfectly linear history. |
| Semi-Linear Merge | Rebase first, then create a merge commit. | A middle ground for strict traceability. |
Method 2: The Manual Merge (Command Line)
Sometimes, you need to merge branches that aren’t protected, or you’re working on a small internal tool in a “Solo Dev” capacity in a place like a home office in Portland.
Step 1: Switch to Target Branch
Open your terminal (PowerShell or Bash) and move to the branch you want to merge into.
Bash
git checkout mainStep 2: Pull Latest
Ensure your local main is identical to the Azure DevOps server.
Bash
git pull origin mainStep 3: Execute the Merge
Merge your feature branch into your current branch.
Bash
git merge feature/new-login-uiStep 4: Push to Azure DevOps
Once the merge is completed locally, send the updated main branch back to the cloud.
Bash
git push origin mainHandling Merge Conflicts
Merge conflicts happen when two developers edit the same line of the same file. Azure DevOps will block the merge until this is resolved.
How to Resolve Conflicts
- Identify the Files: Azure DevOps will list the conflicting files in the PR “Conflicts” tab.
- The “Web Editor” vs. “Local”: For simple conflicts, you can use the Azure DevOps “Conflict Resovler” extension. For complex logic, resolve it locally in VS Code or Visual Studio.
- Choosing a Path: You must decide:
- Keep Source: Use your changes.
- Keep Target: Use what is already in
Main. - Hybrid: Manually combine the logic.
Check out How to Resolve Merge Conflicts in Azure DevOps
Best Practices
To maintain a “Senior” level of authority in your DevOps role, you should implement these policies within your Azure DevOps project settings.
1. Branch Policies
Don’t trust; verify. Enable Branch Policies on your Main branch:
- Require a minimum number of reviewers.
- Check for linked work items.
- Require a successful build. This ensures that nobody merges code that “breaks the build.”
2. The “Squash Merge” Standard
In high-velocity American tech companies, we hate “cluttered” histories. If Sarah makes 45 commits while building a feature, we don’t want those 45 messages in our production log. We use Squash Merge to turn those 45 commits into one clean, meaningful entry.
3. Delete Source Branch
Always check the box “Delete [source branch] after merging.” This prevents your repository from looking like an abandoned construction site with hundreds of “stale” branches.
4. Naming Conventions
Adopt a standardized naming convention across your team:
feat/for new features.bug/for fixes.docs/for documentation changes.refactor/for code cleanup.
Troubleshooting Common Merge Errors
Here are the most frequent issues encountered in Azure DevOps:
- Error: “Identity not authorized”: Usually a permission issue. Ensure your user account has “Contribute” permissions on the target branch.
- Error: “Pre-condition failed”: A branch policy is likely being violated. Check if your build pipeline failed or if you forgot to link a work item.
- Error: “Multiple merge bases”: This happens in complex “criss-cross” merges. The best fix is usually to rebase your branch against the target branch.
Conclusion:
Merging two branches in Azure DevOps is more than a technical command; it is a milestone in the journey of your software. By moving away from manual merges and embracing the Azure DevOps Pull Request workflow, you ensure that your code is vetted, tested, and documented.
Whether you are managing a small team or a massive distributed workforce, these practices will keep your “Main” branch stable and your deployments frequent.
You may also like the following articles:
- How To Recover Deleted Branch In Azure DevOps
- How to Create Pull Request in Azure DevOps
- How to Create a New Repo in Azure DevOps
- How to Delete a Branch in Azure DevOps

I am Rajkishore, and I am a Microsoft Certified IT Consultant. I have over 14 years of experience in Microsoft Azure and AWS, with good experience in Azure Functions, Storage, Virtual Machines, Logic Apps, PowerShell Commands, CLI Commands, Machine Learning, AI, Azure Cognitive Services, DevOps, etc. Not only that, I do have good real-time experience in designing and developing cloud-native data integrations on Azure or AWS, etc. I hope you will learn from these practical Azure tutorials. Read more.
