How to Resolve Merge Conflicts in Azure DevOps

In this guide, I am going to walk you through the three ways to merge conflicts in Azure DevOps: the “Extension” method (the easiest), the “Visual Studio” method (the most visual), and the “Command Line” method (the most reliable).

How to Resolve Merge Conflicts in Azure DevOps

Why Do Merge Conflicts Happen?

Before we fix the problem, let’s understand the root cause. A merge conflict occurs in Azure DevOps when two different branches have competing changes to the same line of a file, or when one branch edits a file that another branch has deleted.

Git is smart, but it is not a mind reader. When it sees two valid but contradictory changes, it effectively throws its hands up.

Common Scenarios

  • Concurrent Editing: Developer A changes line 10 of Login.cs to “Blue”. Developer B changes line 10 to “Red”.
  • File Renaming: Developer A renames style.css to main.css. Developer B edits style.css.
  • The “Cleanup” Conflict: One developer deletes a deprecated function while another developer fixes a bug inside that same function.

Method 1: The Web Interface (The “Pull Request Merge Conflict” Extension)

For years, Azure DevOps users begged for a way to fix simple text conflicts without cloning the repo locally. Microsoft finally answered. They released an official extension that enables this.

Step 1: Install the Extension

Out of the box, Azure DevOps cannot do this. You need to install the “Pull Request Merge Conflict” extension from the Visual Studio Marketplace.

  1. Go to your Organization Settings.
  2. Select Extensions.
  3. Search for “Pull Request Merge Conflict” (created by Microsoft DevLabs).
  4. Click Get it free and install it for your organization. Check out the screenshot below for your reference.
How to Resolve Merge Conflicts in Azure DevOps

Step 2: Navigate to the Pull Request

Once installed, go to the blocked Pull Request (PR). You will notice a new tab has appeared.

  • Overview | Files | Updates | Commits | Conflicts (New!)

Step 3: Resolve the Conflict

  1. Click the Conflicts tab.
  2. You will see a list of conflicting files. Click on a file name.
  3. The screen will split into three panes:
    • Source: Your branch (Incoming changes).
    • Target: The main branch (Current state).
    • Result: The final file.
  4. Navigate line-by-line. You can click a button to “Take Source” or “Take Target.”
  5. Once all red lines are green, click Submit Merge.

Note: This method is perfect for simple logic or text fixes. If the conflict is complex or involves massive refactoring, do not use this. Move to Method 3.

Method 2: The Visual Studio Approach (The GUI Way)

For developers working in the .NET ecosystem (C#, F#, ASP.NET), Visual Studio provides one of the best conflict resolution tools on the market.

Step 1: Fetch the Conflict

You cannot resolve the conflict in Visual Studio if your local machine doesn’t know about it.

  1. Open Team Explorer (or the Git Changes window in VS 2022).
  2. Click Sync to fetch the latest commits from the remote repo.
  3. Attempt to Merge or Rebase the target branch (e.g., main) into your feature branch.
  4. Visual Studio will throw a warning: “Merge completed with conflicts.”

Step 2: Open the Merge Editor

In the “Git Changes” window, you will see a list of “Unmerged Changes.”

  1. Double-click the file with the conflict.
  2. The Merge Editor window opens. This is a powerful 3-way view.
  3. On the Top Left is your code. On the Top Right is the incoming code. The Bottom pane is the result.

Step 3: Check the Boxes

Visual Studio makes this easy with checkboxes.

  • Check the box on the Left to keep your change.
  • Check the box on the Right to overwrite your change with the incoming one.
  • Or, type manually in the bottom window to combine them.

Step 4: Accept Merge

Once the file has no red conflict markers, click the “Accept Merge” button at the top of the window. Commit the change and push it back to Azure DevOps.

Method 3: The Command Line

If you are a DevOps engineer or a non-Windows user (Mac/Linux), you likely live in the terminal. This is the most reliable method because you have full control over every byte of code.

The Conflict Resolution Workflow

StepCommandDescription
1. Checkoutgit checkout feature-branchEnsure you are on your working branch.
2. Pull Targetgit pull origin mainTry to pull the main branch into yours. Git will scream about a conflict.
3. Statusgit statusSee exactly which files are broken (marked as “both modified”).
4. Editcode .Open VS Code (or your editor) to fix the file manually.
5. Addgit add filename.extTell Git “I fixed this file.”
6. Commitgit commitSave the merge.
7. Pushgit push origin feature-branchUpdate Azure DevOps.

Best Practices to Avoid Conflicts

The best way to resolve a merge conflict is to not have one in the first place. While unavoidable in large teams, you can reduce them by 90% with these habits.

1. Pull Early, Pull Often

Do not wait until Friday afternoon to pull changes from main.

I recommend running git pull origin main every morning before you start coding. If you resolve tiny conflicts daily, you avoid the “Mega-Conflict” at the end of the sprint.

2. Keep User Stories Small

If a user story takes 3 weeks to complete, you will drift far away from the main codebase. In the US agile market, we aim to deliver stories in 2-3 days. This ensures your branch is short-lived.

3. Communicate on “Hot Files”

Every project has that one file everyone touches (e.g., appsettings.json, DbContext.cs, or routes.ts).

If you are about to do a massive refactor on a “File,” drop a message in Microsoft Teams or Slack: “Hey team, I’m refactoring the file. Please hold off on file changes for an hour.”

FAQs:

Q: Can I just delete the branch and start over?

A: Technically, yes. If the conflict is too messy, you can backup your files, delete the local branch, and re-clone. However, you lose your commit history. Only do this as a last resort.

Q: What is a “Rebase” and should I use it?

A: A git rebase rewrites history to make it look like you started your work after the latest changes came in. It creates a cleaner history but can be dangerous for beginners. If you mess up a rebase, you can lose code. Stick to merge until you are confident.

Q: Azure DevOps says “Merge Conflict” but won’t let me click anything?

A: You likely haven’t installed the extension mentioned in Method 1. Without that extension, the web UI is read-only for conflicts.

Conclusion

Resolving merge conflicts in Azure DevOps is a rite of passage.

Whether you choose the ease of the Web Extension, the visual comfort of Visual Studio, or the raw power of the Command Line, the principle remains the same: communication. A conflict is just a conversation between two developers that Git couldn’t automate.

So, don’t panic. Read the code, talk to your teammate, and make the merge.

You may also like the following articles:

Azure Virtual Machine

DOWNLOAD FREE AZURE VIRTUAL MACHINE PDF

Download our free 25+ page Azure Virtual Machine guide and master cloud deployment today!