为什么我不能在 Windows 上使用 TortoiseMerge 作为我的 git 合并工具?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5190188/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Why can't I use TortoiseMerge as my git merge tool on Windows?
提问by Ben Blank
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 合并(令人兴奋!),但无法让 Git Gui(来自 Git 1.7.4.msysgit.0 的 0.13.GITGUI)在 Windows 7 上识别 TortoiseMerge(1.6.11.20210 x64)。基于对类似问题的回答,我进行了以下配置更改:
$ 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'
.
不幸的是,当我启动 Git Gui 并尝试“运行合并工具”时,我收到错误Unsupported merge tool 'tortoisemerge'
.
Can anyone tell me what I've done wrong? Here's the relevant sections of my ~/.gitconfig
:
谁能告诉我我做错了什么?这是我的相关部分~/.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. :-/
git mergetool
从命令行运行时,TortoiseMerge 与上述配置配合良好。似乎只有 Git Gui 有问题。:-/
回答by Chris Dragon
If you have the latest git, run this command line once:
如果您有最新的 git,请运行此命令行一次:
git config merge.tool tortoisemerge
git config merge.tool tortoisemerge
Important:Do not add a .exe
extension to the command.
重要提示:不要.exe
向命令添加扩展名。
If that fails, or if you want to add a different merge tool that git doesn't know about, do this:
如果失败,或者如果您想添加一个 git 不知道的其他合并工具,请执行以下操作:
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
- 64 位 git:
C:\Program Files\Git\mingw64\share\git-gui\lib\mergetool.tcl
- 32 位 git:
C:\Program Files (x86)\Git\share\git-gui\lib\mergetool.tcl
Add something like this to mergetool.tcl:
将这样的内容添加到 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:
将新的 tortoisemerge 条目放在其他代码之上:
default {
error_popup [mc "Unsupported merge tool '%s'" $tool]
return
}
Bonus example:
奖金示例:
To use SourceGear diffmerge, add this to mergetool.tcl:
要使用 SourceGear diffmerge,请将其添加到 mergetool.tcl:
diffmerge {
set cmdline [list "C:/Program Files (x86)/SourceGear/DiffMerge/DiffMerge.exe" --merge --result=$MERGED $LOCAL $BASE $REMOTE]
}
回答by Jake
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/
资料来源:http: //programmersunlimited.wordpress.com/2010/07/01/getting-git-to-use-tortoisemerge/
回答by jnrcorp
For the case that I was working on, the mergetool was already set to tortoisemerge, but it could not find it.
对于我正在处理的案例,mergetool 已经设置为 tortoisemerge,但找不到它。
Providing a fully qualified location worked in Windows:
提供在 Windows 中工作的完全合格的位置:
git config --global mergetool.tortoisemerge.cmd "\"C:\Program Files\TortoiseGit\bin\TortoiseGitMerge.exe\" -base:\"$BASE\" -mine:\"$LOCAL\" -theirs:\"$REMOTE\" -merged:\"$MERGED\""
回答by aleemb
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.
尝试TortoiseMerge.exe
从命令行键入以确保它在路径中。如果没有通过我的电脑 > 属性 > 高级 > 环境变量 > 系统变量:路径添加它。
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.
要从命令提示符使用它,git difftool
请在您的 git 工作目录中键入。
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.
它一次显示一个文件,因此您最好安装 TortoiseGit,这使事情更容易处理,即使只是差异部分。
回答by Alex R
This issue appears resolved in the latest git (I have git version 1.9.4.msysgit.1
).
这个问题似乎在最新的 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