Resolve Git conflicts
An advantage to developing an app under version control is that many people can concurrently modify many different versions of the same codebase at the same time. However, this means that sometimes you must resolve conflicts before you can pull changes from the remote repository, or before you merge two branches. Even though conflicts can be frustrating, Visual Studio provides tools to help you resolve them.
Example of conflicts when you try to pull
For example, Raisa wants to push a change to a file. If any commits have been pushed since her last pull, she must pull them down before she can push her commit.
She can view details about the incoming commit from Jamal and see that he has modified the same line of code that she modified.
When she tries to pull, Visual Studio shows her the conflict.
Resolve content conflicts
Content conflicts are the most common type of conflict. In most cases, the Merge window is the easiest way to resolve a content conflict.
Open the merge window.
Select neither, one, or both of the check boxes on either side of the conflict to pull that content into the resolution.
You can add code directly to the resolution if you need to.
To move quickly among conflicts, choose Next Conflict (Keyboard: F9) or Previous Conflict (Keyboard: Shift + F9).
When you are satisfied with the resolution, accept it.
Commit the merge
After you have resolved all the conflicts:
You can commit the merge.
Or, if you cannot resolve all the conflicts (for example, if you don’t have the time or the information you need to proceed), you can undo all your resolutions.
If you decide to commit to the merge:
After you commit, you then push your changes into the remote repository in your team project.
Q & A
Q: I can’t use Visual Studio to resolve some kinds of conflicts. How do I resolve them?
A: You can use the command prompt to resolve them. See Work from the Git command prompt, git-pull, and git-merge.