9

Suddenly, when I try to launch "External merge tool" from Sourcetree, the tool does not appear. I say suddenly, because it worked last time I tried. The dialog remains forever:

image description

Eventually I found this process related to the visual merge (dunno how to copy the command line from windows task manager):

image description

This process, by the way, does not disappear when I press abort, so somebody probably didn't do their homework. Actually, I wouldn't probably notice it if there wasn't six same processes with this command line.

These are my settings:

image description

How do I fix this? I need to merge project and I don't know what to do...

Tomáš Zato
  • 50,171
  • 52
  • 268
  • 778

6 Answers6

12

I found out that this happens when one of the files to be merged has been deleted. In that case, git prints out a command line prompt which sourcetree cannot handle. The git process then ends up hanging forever.

Best way to handle this is to kill the hanging git process and then make the choice manually using use mine/use theirs.

Tomáš Zato
  • 50,171
  • 52
  • 268
  • 778
  • 3
    WARNING!!! Using "mine" or "theirs" will not perform a merge! It will completely replace the file with one version or the other. You can manually edit the file in your editor (not as nice as with a merge tool, but still not too hard) and then mark the file as resolved. – CJ Dennis Apr 23 '18 at 00:24
  • 2
    @CJDennis Thanks for the warning, but note that I was talking about a case when the file was deleted - there is nothing to merge in that case, either you keep the file or delete it. – Tomáš Zato Jul 10 '18 at 06:43
  • That's fine for your specific case, but many people will come here because they want to manually merge two files. Obviously, it's impossible to merge (e.g. in Beyond Compare) when one file is deleted. My problem was that both files existed, and Sourcetree still wouldn't launch Beyond Compare. Deleting one of my files wouldn't have helped me. As specific advice, it's good, as general advice it's potentially very destructive. – CJ Dennis Jul 10 '18 at 08:27
  • Thank you so much for posting this! I have run into this a few times over the years and wondered why it would happen randomly. – RichardWill.Net May 26 '23 at 16:57
3

The issue for me was that I still had the Merge Tool listed as System Default. Changing that configuration also to be DiffMerge seems to have solved it:

DiffMerge

atm
  • 1,684
  • 1
  • 22
  • 24
0

If you cannot start the Sourcetree external merge tool, you can use this:

sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
maxwell
  • 3,788
  • 6
  • 26
  • 40
0

In an addition to Tomáš's answer, you can run the following command in a command prompt in windows, to be able to answer the question git-mergetool asks when one of the files (or even both) is deleted.

Use your own CONFLICTED_FILE_PATH, and you may need to use a different path to point to your git-mergetool:

sh "c:\Program Files\Git\mingw64\libexec\git-core\git-mergetool" -y --tool=sourcetree -- CONFLICTED_FILE_PATH
Paiman Roointan
  • 514
  • 5
  • 17
0

The problem in my case was that I selected the tool itself but not the path to the tool. This seems to be mandatory: enter image description here

You can also see this in your '.gitconfig' file (located in the user directory):

Before

[difftool "sourcetree"]
    cmd = '' \"$LOCAL\" \"$REMOTE\"
[mergetool "sourcetree"]
    cmd = '' \"$BASE\" \"$LOCAL\" \"$REMOTE\" \"$MERGED\"

After

[difftool "sourcetree"]
    cmd = 'C:/Program Files/P4Merge/p4merge.exe' \"$LOCAL\" \"$REMOTE\"
[mergetool "sourcetree"]
    cmd = 'C:/Program Files/P4Merge/p4merge.exe' \"$BASE\" \"$LOCAL\" \"$REMOTE\" \"$MERGED\"
Lonzak
  • 9,334
  • 5
  • 57
  • 88
0

In my case, this was caused by being unable to locate the .gitconfig file. This is a problem, because the .gitconfig file is where the diff and merge settings are stored.

This is because it uses %HOMEDRIVE%%HOMEPATH% to locate it (which is usually C:\Users\%USERNAME%). In my case, this was on a work machine, and they were set to P:\.

While away from the office, my P: drive is unavailable, so it was unable to locate my .gitconfig file as P: didn't exist. Until our company's IT support team is able to provide me with a solution, I worked around this by mounting \\localhost\C$\Users\%USERNAME% as my P: drive, as I'm unable to change the values of %HOMEDRIVE%%HOMEPATH% myself.

(It would be much easier to diagnose if Sourcetree actually gave an error message about this, instead of silently failing)

See the following Atlassian Knowledge base article for more info.

Doctor Jones
  • 21,196
  • 13
  • 77
  • 99