How to resolve merge conflict in pull request in VSTS?
Update
Microsoft just added browser based merges. This may get you out of a pickle for small conflicts.
And offers improved visualizations of the different scenarios as of Sprint 150.
For more complex situations:
You have two options to resolve the conflict, reverse-integrate the changes from the target branch (which creates additional merge commits), or rebase on the target branch (which leaves your history nice and clean).
Merge from target to current branch prior to completing the PR.
You need to clone the repo locally, perform a merge from the target branch to your branch and push those changes up to the repository. VSTS will detect the changes and update the pull request.
-------o3 PR
/
---------o1-o2 target
Thus merge target (o2)
to PR
:
-------o3-o4 PR
/ /
---------o1----------o2 target
Then complete the PR
-------o3-o4 PR
/ / \
---------o1----------o2--o5 target
Rebase the PR branch to include the latest changes on target
Alternatively, you can clone the repo locally, rebase the PR branch on the latest version of the target branch, solve all issues from the rebase and force-push the changes back to the PR branch. VSTS will detect the changes and update the pull request.
-------o3 PR
/
---------o1-o2 target
Thus rebase o3
onto o2
:
-------o3 PR
/
---------o1-o2 target
Then complete the PR
(with Fast-forward merge in the case below):
---------o1-o2-o3 target
- Open your project with Visual Studio.
- Open View > Team Explorer
- Change to Branches tab.
- Double click to the branch you intend to merge (e.g. dev).
- Right Click > Merge From > Select
Merge from branch: master,
Into current branch: dev - Click Merge button
- Choose the conflict file(s)
- Then resolve the conflicts. You can click the left or right checkbox for the section you want to include.
- Then commit the merge
- Done.
To answer @metabuddy's question:
And then what? This only shows how to resolve conflicts locally, I can't push the target nor source branch directly to VSTS because I have branch policies which require pull requests to be made from feature branches.
You can follow the steps above. Just the source branch and target branch will be slightly different.
- branch merge from: master
- branch into: your-feature-branch
- Create Pull Request to merge from your-feature-branch into master