Using an external merge tool does not work on SourceTree

I am running OS X.10, Xcode 7 and SourceTree 2.

When I select a conflicted file and Launch an external merge tool, there is a window that appears very briefly... and then nothing happens.

I tried (see this help page) sudo ln -s /Developer/usr/bin/opendiff /usr/bin/opendiff but it did not work (I got the message ln: /usr/bin/opendiff: File exists).

What should I do?

PS:

Here is a picture of the window that briefly appears.

enter image description here

PPS:

Here are the SourceTree preferences:

enter image description here


My problem was that I was running a previous version of Xcode and I hadn't set the command line tools.

Select the tools in Xcode's preferences -> locations:

enter image description here

Then run this command in terminal to verify:

git config --global -l

The git command will print out the path for the diff tool, amongst other config info. If it's not configured, it will output an error with something along the lines of the following:

xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools),

Assuming you are on latest version of SourceTree (Version 2.0.5.5 (2.0.5.5))

Try adding the following manually to your .gitconfig (or verify that SourceTree has put these exact lines)

[mergetool "sourcetree"]
    cmd = /Applications/SourceTree.app/Contents/Resources/opendiff-w.sh \"$LOCAL\" \"$REMOTE\" -ancestor \"$BASE\" -merge \"$MERGED\"
    trustExitCode = true

Or you could just enable "Allow sourcetree to modify your global mercurial and git configuration files." in Preferences -> General tab

These lines will be automatically updated