'FileMerge quits immediately after launching from SourceTree

I regularly use Atlassian SourceTree (on Mac OS X) to launch FileMerge to resolve git merge conflicts. Out of the blue it has stopped working: when I right click and select Resolve Conflicts > Launch External Merge Tool, FileMerge launches, creates its intermediate files, then immediately exits. SourceTree interprets that as the merge process being complete.

What's the issue and how can I debug/fix it?

I note that a previous question 'SourceTree filemerge quits immediately and creates 4 files. How to fix it?' does not address this particular scenario (for one, it says FileMerge quits in the title, but in the body it says FileMerge displays /dev/null as one of the panels. Additionally, my merge conflict is not due to a removed file.)



Solution 1:[1]

For me, SourceTree didn't even launch FileMerge. When clicking Launch External Merge Tool nothing happened.

Moreover, running opendiff in Terminal worked as expected:

$ opendiff
opendiff[64176:5561154] too few arguments
opendiff[64176:5561154] usage: opendiff file1 file2 [-ancestor ancestorFile] [-merge mergeFile]

What helped me was manually configuring SourceTree to use FileMerge via the opendiff command with the following arguments: $LOCAL $REMOTE -ancestor $BASE -merge $MERGED

SourceTree manually configure to use opendiff

This way, SourceTree opens FileMerge as expected.

Solution 2:[2]

This helped: https://gist.github.com/kylefox/4512777

Tell system when Xcode utilities live:

sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer

Set "opendiff" as the default mergetool globally:

git config --global merge.tool opendiff

Solution 3:[3]

If Xcode has recently updated itself, you may need to agree to the new license terms. If you have not agreed to the license terms, FileMerge (when launched from SourceTree) will quit immediately.

To check for this, open a shell and run as your usual user:

$ opendiff

If the license is the problem, it will tell you. To agree to the new license terms, you'll need to run open diff using sudo:

$ sudo opendiff

After agreeing to the license terms, you can now retry launching FileMerge from SourceTree using Resolve Conflicts > Launch External Merge Tool. FileMerge should launch and behave normally.

Solution 4:[4]

This also works to resolve the message "xcode-select: error: tool 'opendiff' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance":

sudo xcode-select -s /Applications/Xcode.app/Contents/Developer

Solution 5:[5]

I have encountered this problem and solved it with the answer here
So this time, when I had it again, I thought the same issue happened...

And after trying for almost an hour, I've realized that the Diffmerge (or any external diff tool) did not open because there was no file in the current branch to merge.

This can happen when you do Cherry Pick where the commits can be jumpy. Added this answer to remind people who are going to have the same issue.

Solution 6:[6]

Tick Allow Sourcetree to modify your global... solves the issue for me source tree preference

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Tom Kraina
Solution 2 vulmer
Solution 3 Greg Kopff
Solution 4 fabe
Solution 5 Nathan Do
Solution 6 Hai Feng Kao