How to resolve merge conflicts in sourceTree
Asked by David Newey:

I have a develop branch that I just committed files to. During the commit I got a pop-up that said there were merge conflict due to an earlier commit by another developer. Instructions in the pop-up said to go to 'Resolve Conflicts' and use those options. The only options I am given under Resolve Conflicts are 'Restart Merge' or 'Mark Unresolved' neither of which is an acceptable solution. How do i actually resolve merge conflicts?


Answers:
author: Tim Crall
body: You can resolve merge conflicts manually by opening the conflicted files in any editor. The conflicts have been marked up like this:

```
&lt;&lt;&lt;&lt;&lt;&lt;&lt; HEAD// code from base branch=======// code from merged branch&gt;&gt;&gt;&gt;&gt;&gt;&gt; branch1
```

You can then manually edit the code to contain one or the other or a synthesis of both changes and remove the markups. Then stage and commit to complete the merge.

comments: author: Jayan Anuranga
body: good


author: nick t
body: ugg


author: Thomas Britt
body: I agree with nick t, that is no way to resolve conflicts.


author: Kenneth Sizer
body: Like "start walking West" to reach California, this is \*a\* way, but it would not be my first choice.


author: gmonroe
body: Not only does this seem like a clunky fix at best, it doesn't work. I edit the file, and it just gives me the merge error again.


author: Ryan Daly
body: Sourcetree seems to not care about merge conflicts. I know how to resolve conflicts by editing files. But isn't Sourcetree supposed to be better than this? There seems to be no interface for it.


author: Seth
body: You have to configure SourceTree to use your merge software. In the Diff tab of the Options dialog, look for the Merge tool dropdown for a list of programs that SourceTree knows how to use out of the box.

comments: author: Daniel Russell
body: I don't understand where to see conflicts and what files need resolution etc. It's so confusing. Where do I click after I hit merge and get the dialog popping up saying to do so? Literally lost.


author: David_Knoll

author: Mariana Schiff
body: The popup dialog after the merge leaves you in the middle of nowhere. It's not clear where to find the Options dialog.

After reading all the comments here and clicking around in the tool, I finally figured out a reasonable way to do this. Please note that this describes how I did it; it may look different for you:

1. If you haven't set up an external merge tool:
   1. On the main menu, click on Tools -\> Options to open the Options dialog
   2. On the Diff tab, in the External Diff / Merge frame, in the Merge Tool dropdown, select one of the available tools. If your tool is not listed, select Custom. In this case, you need to provide the correct arguments for your tool based on the cryptic note provided. I gather you need to surround each argument in quotes, and escape the quotes with backslashes.
   3. Click OK to close the Options dialog.
2. In Sourcetree, after dismissing the popup that tells you that you have conflicts, click on the "Uncommited Changes" row of the tree.
3. On the list of Unstaged files at the bottom, you'll find some that have an orange triangle icon with an exclamation sign in it. These are the files with conflicts. (Note that they are also listed in Staged Files, but they show no differences there.)
4. Right-click on a conflicted file, and select Resolve Conflicts -\> Launch External Merge Tool (of course, you could select one of the other options if it's that clear-cut).
5. If you're lucky enough that your tool is launched correctly, perform your changes.
6. Once you've performed the merge, save the file and close the external tool.
7. Then you'll be able to commit your changes. In my case, they were already staged.

If you don't have a merge tool, you'll need to edit the files as explained below by Tim Crall.


author: Allen Maizenberg
body: exactly what i needed. thank you for adding


author: Pablo Oliveira
body: Friend, what software are you using to diff externally? have indication


author: Mariana Schiff
body: I use WinMerge, but there are other tools that would work as well.