Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to resolve merge conflicts in sourceTree

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?

2 answers

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

<<<<<<< HEAD
// code from base branch
// code from merged branch
>>>>>>> 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. 


Like # people like this
Like # people like this

I agree with nick t, that is no way to resolve conflicts.

Like # people like this

Like "start walking West" to reach California, this is *a* way, but it would not be my first choice.

Like # people like this

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.

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.

Like micsun-al likes this

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.

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.

Like # people like this

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.

Like # people like this

exactly what i needed. thank you for adding

Friend, what software are you using to diff externally? have indication

I use WinMerge, but there are other tools that would work as well.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Sourcetree

Tip from the team: configure your repos for hosting goodness!

Supported Platforms macOS Windows We recently introduced support for additional hosting services such as GitHub Enterprise, GitLab (Cloud, Community Edition, Enterprise Edition), and...

5,692 views 4 12
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you