Resolve merge conflicts in Visual Studio (original) (raw)

When you merge one branch into another, file changes from commits in one branch can conflict with the changes in the other. Git attempts to resolve these changes by using the history in your repo to determine what the merged files should look like. When it isn't clear how to merge changes, Git halts the merge and tells you which files conflict.

Prevent merge conflicts

Git is good at automatically merging file changes in most circumstances, as long as the file contents don't change dramatically between commits. If your branch is far behind your main branch, consider rebasing your branches before you open a pull request. Rebased branches will merge into your main branch without conflicts.

Resolve merge conflicts

Screenshot that shows a merge conflict after a push.

Screenshot of merge conflict after a push.

Screenshot that shows merge conflict status in the Git Changes window.

Screenshot of merge conflict status in the Git Changes window.

If you set your .gitconfig file to use a third-party diff tool such as BeyondCompare or KDiff3, Visual Studio respects it. Whenever Visual Studio would normally display a diff, a separate window is opened in the tool of your choice. For an example, see this Stack Overflow question.