Home / Questions / How to Merging code and resolving code conflicts
Explanatory Question

How to Merging code and resolving code conflicts

👁 159 Views
📘 Detailed Answer
🕒 Easy to Read
Read the answer carefully and go through the related questions on the right side to improve your understanding of this topic.

Answer with Explanation

Sometimes, when you get the latest code from a branch into Visual Studio, the code stored on the server has changes that are different from the changes that you made locally. This is a merge conflict.

When Visual Studio encounters a merge conflict, it attempts to resolve it automatically. Any such resolution is in the output log. If any conflicts fail to resolve automatically, they appear in a new window that prompts you to tell Visual Studio what it should do for each conflicting file.

The Resolve Conflicts window gives you the following options for each file:

  • Take Source - Use the file that you pulled from source control, erasing all your local changes.
  • Keep Local - Keep your local file, losing any changes that are present in source control.
  • Merge using Merge Tool - View both versions of the file side by side, choosing to keep or discard each change in either version, one at a time.

You can't check in a changeset until there are no unresolved merge conflicts, so mastering these tools is key to your success as a member of a development team.