Skip to content

Resolve Merge Conflicts-

*If you do not have a merge conflict yet, continue to Complete a PR, otherwise continue to resolve them.

Visualizing merge conflicts

Recall that a merge conflict occurs when developers work in parallel and change the same lines of code, resulting in changes on both the source and target branches. Git cannot automatically resolves changes when two people want to make separate changes to the same code lines.

Branches Resolving conflicts locally by pulling in the target branch from the remote repository.

Comparing and resolving

Now it's time to compare your changes with the incoming changes and decide how to move forward. You can run git diff or you can use your code editor to see the conflict.

Merge In this example using using Visual Studio Code, the conflict occurred on line 22 and Git's messaging surrounded the code commits. Line 23 (the Current Change) had been committed locally and line 25 (Incoming Change) had been merged into ADO earlier. The IDE provides one-click solutions with options to resolve the conflict, but you will need to carefully choose which ones to select.

You will need to pair with your team to determine how to resolve and which change(s) to keep, make, combine, or alter altogether. Keep in mind there is no default solution to resolve conflicts.

The reality is that merge conflicts will happen and you should be prepared and know how to embrace them. To resolve them, your team should be careful to logically choose the correct outcome and not blindly accept one change over another. Use local Git tools to continue development and determine the best solution. When deciding which changes to take, consider that you can select the first change, the second change, or a combination of both changes. It will require pairing to determine the best choice.

Commit new changes

Once you have agreed to your new code, you will need to make a new commit with the reconciled code changes. However, before committing, you should validate by performing the "local build" and opening the HTML page in your browser. If the changes look right, continue to commit your changes.