Git difftool不启动外部DiffMerge程序 [英] Git difftool not launching external DiffMerge program
问题描述
我一直沿着 Dave博客条目这个答案中的链接,因为我在Windows 7上并且使用SourceGear的DiffMerge工具。我已将 git \ cmd
目录添加到我的PATH系统变量中,并将 git-diff-diffmerge-wrapper.sh
b
$ b
#!/ bin / sh
C:\ Program Files \ SourceGear\Common\DiffMerge\sgdm.exe$ 1$ 2| cat
(是的,这是DiffMerge的正确路径。)
我编辑了我的 .gitconfig
文件以包含 diff
和 difftool
chunks(我直接从帖子中复制了这些行,并且他在注释掉的 #external
行中留下了一行。 )
[diff]
#external = git-diff-wrapper .sh
tool = diffmerge
[difftooldiffmerge]
cmd = git-diff-diffmerge-wrapper.sh$ LOCAL$ REMOTE
所以我去 git bash
并且做 git difftool HEAD〜67b8679 - js / site / pizzabuilder.js
并回车。什么都没发生。如果我做了 git difftool HEAD〜67b8679
,把我想要的文件关掉,我得到这个:
查看:'js / angular / hutlovers / hutlovers.js'
启动'diffmerge'[Y / n]:Y
C:\ Program Files(x86)\Git / libexec / git-core / mergetools / defaults:第17行:git-diff-diffmerge-wrapper.sh:找不到命令
查看:'js / angular /本地化/ StoreListCtrl.js'
启动'diffmerge'[是/否]:n
查看:'js / pizzahut / site / browser_version.js'
启动'diffmerge' [Y / N]:n
查看:'js / pizzahut / site / dashboard.js'
启动'diffmerge'[是/否]:n
它继续执行提交之间不同的所有文件,但它不会启动DiffMerge。我不知道如何解释错误。什么命令没有找到? difftool
?我在git中运行了1.7.11,并且从版本1.6.3开始,git包含了 difftool
。
(eval $ merge_tool_cmd)当我看到错误中引用的文件的第17行时,
作为此块的一部分:
<$ p
merge_tool_cmd = $ $ b $ merge_tool_cmd = $ $(get_merge_tool_cmd$ 1)
if test -z$ merge_tool_cmd
then
status = 1
break
fi
(eval $ merge_tool_cmd)
status = $?
return $ status
}
任何人都可以帮我吗?我是一个每天使用 git
的用户,但几乎不是高级用户,而且我对Windows shell脚本一无所知,所以按照该帖子中的说明几乎是限制我的知识在这一点上。
DiffMerge
这个很好的帮助,但这是我对DiffMerge的 difftool
的配置。 请注意,我使用的是msysgit Bash (不知道Cygwin或PoshGit用户是否会有所不同):
[diff]
tool = dm
[difftooldm]
cmd = C:/ Program \\ Files / SourceGear / Common /DiffMerge/sgdm.exe \$ LOCAL \\$ REMOTE\
我目前正在使用Git 2.0,但我似乎已经记得使用Git 1.8.x或者甚至早于Git 1.7.x来设置它,所以试试看看它是否有效。
Beyond Compare 3 Pro的额外奖励
实际上,我现在在Windows上使用之外,尽管有时我仍然会使用DiffMerge。以下是我的 difftool
设置,如果您想进行切换:
[合并]
工具= bc3
[diff]
工具= bc3
[difftooldm]
cmd = C :/ Program \\ Files / SourceGear / Common / DiffMerge / sgdm.exe \$ LOCAL \\$ REMOTE\
[difftoolbc3]
cmd = \c:/ program files(x86)/ beyond compare 3 / bcomp.exe \\$ LOCAL \\$ REMOTE \
[mergetoolbc3]
cmd =\c:/ program files(x86)/ beyond compare 3 / bcomp.exe \\$ LOCAL \\$ REMOTE \\$ BASE \\$ MERGED \
I've been following the directions in the "blog entry by Dave" link in this answer as I'm on Windows 7 and do use SourceGear's DiffMerge tool. I've added the git\cmd
directory to my PATH system variable and put my git-diff-diffmerge-wrapper.sh
file in there:
#!/bin/sh
"C:\Program Files\SourceGear\Common\DiffMerge\sgdm.exe" "$1" "$2" | cat
(Yes, it's the correct path for DiffMerge.)
I've edited my .gitconfig
file to include the diff
and difftool
chunks (I copied the lines directly from the post, and he does leave in the commented-out #external
line. I added this to the end of my file; is that OK? )
[diff]
# external = git-diff-wrapper.sh
tool = diffmerge
[difftool "diffmerge"]
cmd = git-diff-diffmerge-wrapper.sh "$LOCAL" "$REMOTE"
So I go to git bash
and do git difftool HEAD~ 67b8679 -- js/site/pizzabuilder.js
and hit enter. Nothing happens. If I do git difftool HEAD~ 67b8679
, leaving off the file I want, I get this:
Viewing: 'js/angular/hutlovers/hutlovers.js'
Launch 'diffmerge' [Y/n]: Y
C:\Program Files (x86)\Git/libexec/git-core/mergetools/defaults: line 17: git-diff-diffmerge-wrapper.sh: command not found
Viewing: 'js/angular/localization/StoreListCtrl.js'
Launch 'diffmerge' [Y/n]: n
Viewing: 'js/pizzahut/site/browser_version.js'
Launch 'diffmerge' [Y/n]: n
Viewing: 'js/pizzahut/site/dashboard.js'
Launch 'diffmerge' [Y/n]: n
It continues for all of the files that are different between the commits, but it never launches DiffMerge. I don't know how to interpret the error; what command is not found? difftool
? I'm running 1.7.11 in git, and difftool
is supposedly included with git starting with version 1.6.3.
When I look at line 17 of the file referenced in the error, this is what's there:
( eval $merge_tool_cmd )
as part of this block:
diff_cmd () {
merge_tool_cmd="$(get_merge_tool_cmd "$1")"
if test -z "$merge_tool_cmd"
then
status=1
break
fi
( eval $merge_tool_cmd )
status=$?
return $status
}
Can anyone help me out? I'm a daily user of git
, but hardly a power user, and I know nothing about Windows shell scripts, so following the directions in that post is pretty much the limits of my knowledge at this point.
DiffMerge
Not sure if this well help, but this is my configuration for difftool
with DiffMerge. Note that I'm using msysgit Bash (not sure if it will be different for Cygwin or PoshGit users):
[diff]
tool = dm
[difftool "dm"]
cmd = C:/Program\\ Files/SourceGear/Common/DiffMerge/sgdm.exe \"$LOCAL\" \"$REMOTE\"
I'm currently using Git 2.0, but I seem to recall having set this up with either Git 1.8.x or maybe even as early as Git 1.7.x, so try it out and see if it works.
Bonus with Beyond Compare 3 Pro
I actually do most of my diffing on Windows nowadays with Beyond Compare 3 Pro, though sometimes I will still use DiffMerge. Here are all of my difftool
settings if you want to make the switch:
[merge]
tool = bc3
[diff]
tool = bc3
[difftool "dm"]
cmd = C:/Program\\ Files/SourceGear/Common/DiffMerge/sgdm.exe \"$LOCAL\" \"$REMOTE\"
[difftool "bc3"]
cmd = "\"c:/program files (x86)/beyond compare 3/bcomp.exe\" \"$LOCAL\" \"$REMOTE\""
[mergetool "bc3"]
cmd = "\"c:/program files (x86)/beyond compare 3/bcomp.exe\" \"$LOCAL\" \"$REMOTE\" \"$BASE\" \"$MERGED\""
这篇关于Git difftool不启动外部DiffMerge程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!