Resolving Pull Request Conflicts
Overview
This article explains the reasons behind Pull Request conflicts and the common scenarios in which they occur. It also provides detailed, step-by-step instructions for reviewing and resolving these conflicts effectively.
What causes a Pull Request conflict?
A Pull Request conflict can occur when two branches have commits that affect the same line of code, and the Pull Request is unable to automatically determine which line to preserve. To illustrate how this can happen, see the diagram below.

In this example, branch_b is created from branch_a. Next, a change affecting the myName function is committed to branch_b, and a different change to the function is committed to branch_a. When a Pull Request is created to merge branch_b into branch_a, the pull request detects that the same line of code has changed in both branches, resulting in a conflict. In the following section, you will see two different options for resolving the conflict.
How to resolve a Pull Request conflict?
When a Pull Request encounters a conflict, you can resolve it by either retaining or overwriting the target's changes. For multiple conflicts, address each one separately using the most appropriate method; it's okay to use different approaches for different conflicts.
Retain Target Changes
To resolve conflicts using this method, commit the conflicting lines from the target branch into the source branch. See the diagram for an illustration, and refer to the step-by-step instructions provided in the Retain Target Changes section below.
This method uses the Resolve Conflicts function in a Pull Request to automatically commit the changes to the source branch.

Overwrite Target Changes
To resolve conflicts using this method, commit the conflicting lines from the source branch into the target branch. See the diagram for an illustration, and refer to the step-by-step instructions provided in the Overwrite Target Changes section below.
This method requires you to manually commit the changes from the source branch into the target branch.

Resolving Conflicts
Review Conflicts
Click Resolve conflicts.

Click a component to view the conflicts.

All components need to be reviewed and resolved.
Review the conflicting code in the component and determine how to resolve the conflict.

See the What causes a Pull Request conflict? section above for an explanation of Pull Request conflicts.
There are two ways to resolve a Pull Request conflict. See the following sections for instructions about how to perform each.
Retain Target Changes: This method keeps the target's code by committing the conflicting lines from the target branch into the source branch.
Overwrite Target Changes: This method keeps the source's code by committing the conflicting lines from the source branch to the target branch.
For multiple conflicts, address each one separately using the most appropriate method; it's okay to use different approaches for different conflicts.
Retain Target Changes
This method uses the Resolve conflicts feature built into a Pull Request.
Click a component with conflicts to resolve.

Click Accept all to retain all lines, or click the Right Arrow for each line to retain. This copies the selected line from the target branch to the source branch.

Once all necessary changes have been made to the source branch, click Resolve. This marks a component as Resolved so you can keep track of your changes.
Click Back.

Repeat this process for all components with conflicts.
Once all components are marked as Resolved, click Resolve conflicts.

Enter a Commit message.
Click Resolve.

After resolving the conflicts, the Pull Request will check for conflicts again.
If there are no more conflicts, the Pull Request message will be green and state "This branch is able to merge".

If conflicts persist in the Pull Request, review and resolve them. Repeat until all issues are resolved.
Overwrite Target Changes
This method requires manually editing and committing changes to the target branch.
To make it easier to resolve conflicts when overwriting changes in the target branch, note the specific lines and components causing conflicts as you review the Pull Request.
Click Code from the left sidebar menu.
Click the target branch of the Pull Request.

Click the Three Vertical dots at the right end of a component with conflicts in the Pull Request.
Click Edit.

Edit the conflicting line or lines of code to match the source branch.
Click Commit changes.

Enter a Commit message.
Click Commit.

Repeat this process for all components with conflicts.
Once all components with conflicts are edited to match the source branch, return to the Pull Request.
Click Pull requests from the left sidebar menu.
Click the Pull Request to check if all conflicts are resolved.

If there are no more conflicts, the Pull Request message will be green and state "This branch is able to merge".

If conflicts persist in the Pull Request, review and resolve them. Repeat until all issues are resolved.
Last updated
Was this helpful?
