为什么我不能在Windows上使用TortoiseMerge作为我的git合并工具?

我试图执行我的第一个Git合并(令人兴奋的!),但无法让Git Gui(Git 1.7.4.msysgit.0中的0.13.GITGUI)识别Windows 7上的TortoiseMerge(1.6.11.20210 x64)。基于对类似问题的回答 ,我做了以下configuration更改:

$ 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" $ 

不幸的是,当我启动Git Gui并尝试“运行合并工具”时,收到错误Unsupported merge tool 'tortoisemerge'

谁能告诉我我做错了什么? 以下是我的~/.gitconfig的相关部分:

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

更新

从命令行运行git mergetool时,TortoiseMerge可以正常工作。 看来只有Git Gui有问题。 : – /

更新

原来的答案现在已经过时了。

如果你有最新的git只是做一次性的git config merge.tool tortoisemerge

重要说明:不要将.exe扩展名添加到该命令。

===原来的答案(现在已经过时)===

我没有tortoisemerge安装,所以我不能testing这个,但我敢肯定的问题是,git gui使用一个名为C:\ Program Files文件(x86)\ Git \共享\ git-gui \ lib \ mergetool.tcl来定义它的每一个合并工具,并且它显示在.gitconfig中定义的合并工具的“不支持的合并工具”错误,这个合并工具与在mergetool.tcl中定义的合并工具不匹配。

所以,要使它工作,你应该能够像这样添加到mergetool.tcl:

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

把这个新的tortoisemerge条目放在这个其他的代码之上:

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

尝试这个:

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

资料来源: http : //programmersunlimited.wordpress.com/2010/07/01/getting-git-to-use-tortoisemerge/

对于我正在研究的案例,合并工具已经被设置为乌龟,但找不到它。

在Windows中提供完全合格的位置:

 git config --global mergetool.tortoisemerge.cmd "\"C:\\Program Files\\TortoiseGit\\bin\\TortoiseGitMerge.exe\" -base:\"$BASE\" -mine:\"$LOCAL\" -theirs:\"$REMOTE\" -merged:\"$MERGED\"" 

尝试从命令行键入TortoiseMerge.exe ,以确保它在path中。 如果不通过“我的电脑”>“属性”>“高级”>“环境variables”>“系统variables:path”添加它。

然后从命令提示符通过以下命令进行configuration

 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 

要从命令提示符使用它,从你的git工作目录中inputgit difftool

它一次显示一个文件,所以你最好安装TortoiseGit,这样可以更容易处理,即使只是为了diff部分。

这个问题似乎在最新的git(我有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