Why can't I use TortoiseMerge as my git merge tool on Windows?
Asked Answered
J

5

47

I'm trying to perform my first Git merge ever (exciting!), but can't get Git Gui (0.13.GITGUI from Git 1.7.4.msysgit.0) to recognize TortoiseMerge (1.6.11.20210 x64) on Windows 7. Based on an answer to a similar question, I've made the following configuration changes:

$ git config --global merge.tool tortoisemerge
$ git config --global mergetool.tortoisemerge.cmd 'TortoiseMerge.exe -base:"$BASE" -mine:"$LOCAL" -theirs:"$REMOTE" -merged:"$MERGED"'
$ git config --global --list
...snip...
merge.tool=tortoisemerge
mergetool.tortoisemerge.cmd=TortoiseMerge.exe -base:"$BASE" -mine:"$LOCAL" -theirs:"$REMOTE" -merged:"$MERGED"
$

Unfortunately, when I start Git Gui and attempt to "Run Merge Tool", I receive the error Unsupported merge tool 'tortoisemerge'.

Can anyone tell me what I've done wrong? Here's the relevant sections of my ~/.gitconfig:

[merge]
        tool = tortoisemerge
[mergetool "tortoisemerge"]
        cmd = TortoiseMerge.exe -base:\"$BASE\" -mine:\"$LOCAL\" -theirs:\"$REMOTE\" -merged:\"$MERGED\"

Update

TortoiseMerge works fine with the above config when running git mergetool from the command line. It seems that only Git Gui has problems with it. :-/

Jail answered 4/3, 2011 at 5:50 Comment(6)
Is TortoiseMerge.exe in your path? Have you tried specifying the full path?Gladine
@Ben — It is indeed in my path, and specifying the full path doesn't seem to have any effect. :-/Jail
Do you have any space in the files you want to merge?Eng
@Eng — In the file names? No.Jail
@Ben: ok, I was just checking if it has anything to do with code.google.com/p/msysgit/issues/detail?id=479#makechanges and the TortoiseMerge request at tortoisesvn.tigris.org/ds/…Eng
@Eng — You got my hopes up with that one! Note of the paths within the repo had spaces, but an ancestor folder did. Moved the repo to a higher folder so that there weren't any spaces anywhere in the paths, but no change. Tried every permutation of arguments, quoting, and cmd /c suggested in that issue, and even tried upgrading Git and using mergetool.tortoisemerge.path instead of .cmd, all to no avail. :-(Jail
H
60

If you have the latest git, run this command line once:

git config merge.tool tortoisemerge

Important: Do not add a .exe extension to the command.

If that fails, or if you want to add a different merge tool that git doesn't know about, do this:

Open one of the following in an editor:

  • 64-bit git: C:\Program Files\Git\mingw64\share\git-gui\lib\mergetool.tcl
  • 32-bit git: C:\Program Files (x86)\Git\share\git-gui\lib\mergetool.tcl

Add something like this to mergetool.tcl:

tortoisemerge {
    set cmdline [list TortoiseMerge.exe -base:"$BASE" -mine:"$LOCAL" -theirs:"$REMOTE" -merged:"$MERGED"]
}

Put the new tortoisemerge entry above this other code:

default {
        error_popup [mc "Unsupported merge tool '%s'" $tool]
        return
}

Bonus example:

To use SourceGear diffmerge, add this to mergetool.tcl:

diffmerge {
    set cmdline [list "C:/Program Files (x86)/SourceGear/DiffMerge/DiffMerge.exe" --merge --result=$MERGED $LOCAL $BASE $REMOTE]
}
Huerta answered 13/4, 2013 at 3:58 Comment(4)
Well, I'll be darned. Two years on and we've finally got a solution for this one!Jail
I have the latested git-for-windows 2.12.2 install on a 64 bit windows, but the tortoisegitmerge.exe is not in the PATH, so both the updated answer and the outdated answer does not work. Both reported: Unsupported merge tool 'tortoisemerge'. While, my tortoisegit is install in the E:\Program Files\TortoiseGit\bin\TortoiseGitMerge.exe. So, any ideas? Thanks.Convoluted
Perfectly comment. Work very well!Forborne
It's disappointing that git gui's mergetool.tcl doesn't support mergetool.$tool.cmd :(Bandur
P
16

Try this:

[merge]
tool = tortoise

[mergetool "tortoise"]
cmd = "TortoiseMerge.exe" -base:"$BASE" -theirs:"$REMOTE" -mine:"$LOCAL" -merged:"$MERGED"

Source: http://programmersunlimited.wordpress.com/2010/07/01/getting-git-to-use-tortoisemerge/

Portent answered 4/3, 2011 at 6:2 Comment(3)
Same problem, I'm afraid. (Though now the error is Unsupported merge tool 'tortoise', of course.)Jail
Had to put the full path and escape double quotes: cmd = \""c:/Program Files/TortoiseSVN/bin/TortoiseMerge.exe"\" -base:"$BASE" -theirs:"$REMOTE" -mine:"$LOCAL" -merged:"$MERGED"Manmade
I had a problem with the files, which have spaces in their names. And this syntax can workaround problem: cmd = \""c:/Program Files/TortoiseGIT/bin/TortoiseGitMerge.exe"\" -mine \"$REMOTE\" -base \"$LOCAL\". This works for TortoiseGitMerge, not TortoiseMergeSpinach
K
6

For the case that I was working on, the mergetool was already set to tortoisemerge, but it could not find it.

Providing a fully qualified location worked in Windows:

git config --global mergetool.tortoisemerge.cmd "\"C:\\Program Files\\TortoiseGit\\bin\\TortoiseGitMerge.exe\" -base:\"$BASE\" -mine:\"$LOCAL\" -theirs:\"$REMOTE\" -merged:\"$MERGED\""
Koah answered 31/10, 2013 at 15:54 Comment(0)
J
2

Try typing TortoiseMerge.exe from the command line to make sure it's in the path. If not add it via My Computer > Properties > Advanced > Environment Variables > System Variables:Path.

Then from command prompt configure it via the following commands

git config --replace --global diff.tool tortoisemerge
git config --replace --global difftool.diffmerge.cmd "TortoiseMerge.exe -base:\"$BASE\" -theirs:\"$REMOTE\" -mine:\"$LOCAL\" -merged:\"$MERGED\""
git config --replace --global difftool.prompt false

To use it from the command prompt, type git difftool from your within your git working directory.

It shows the files one at a time so you're still better off installing TortoiseGit which makes things easier to handle, even if just for the diff part.

Jeanette answered 25/3, 2012 at 15:31 Comment(1)
How can I open GUI based tool to merge all conflict files from Git cmd?Melodee
C
1

This issue appears resolved in the latest git (I have git version 1.9.4.msysgit.1).

C:\git\build>git mergetool

This message is displayed because 'merge.tool' is not configured.
See 'git mergetool --tool-help' or 'git help config' for more details.
'git mergetool' will now attempt to use one of the following tools:
tortoisemerge emerge vimdiff

C:\git\build>git config merge.tool tortoisemerge

C:\git\build>git mergetool
No files need merging
Catfall answered 1/4, 2015 at 0:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.