所以我看到了一些关于让DiffMerge成为git的mergetool
和difftool
的问题。从本质上讲,它归结为在PATH
和.gitconfig
中使用DiffMerge(sgdm.exe),如下所示:
[diff]
tool = DiffMerge
[difftool "DiffMerge"]
cmd = 'C:/Program Files/SourceGear/Common/DiffMerge/sgdm.exe' "$LOCAL" "$REMOTE"
[merge]
tool = DiffMerge
[mergetool "DiffMerge"]
cmd = 'C:/Program Files/SourceGear/Common/DiffMerge/sgdm.exe' -merge -result="$MERGED" "$LOCAL" "$BASE" "$REMOTE"
trustExitCode = true
keepBackup = false
当我运行git difftool file1 file2
时,没有任何反应。没有错误代码,也没有启动DiffMerge。从Git Bash和Windows命令行,我可以运行sgdm file1 file2
并启动DiffMerge。
我已将cmd
中的.gitconfig
修改为没有路径或扩展名(例如sgdm
),但仍无济于事。
有没有人遇到过这个?有什么明显的东西我不见了吗?我觉得我错过了一些明显的东西。
答案 0 :(得分:13)
我使用SourceGear DiffMerge的.gitconfig
是:
[mergetool "diffmerge"]
cmd = \"C:\\program files\\sourcegear\\common\\diffmerge\\sgdm.exe\" --merge --result=$MERGED $LOCAL $BASE $REMOTE
(显然,如果你喜欢另一方,请翻转$LOCAL
和$REMOTE
。)
答案 1 :(得分:5)
这对我来说很有效。 (Windows 7,Git的最新版本。)
确保sgdm.exe位于环境路径中。
[diff]
tool = sgdm
[difftool "diffmerge"]
cmd = sgdm $LOCAL $REMOTE
[merge]
tool = sgdm
[mergetool "diffmerge"]
cmd = sgdm --merge --result=$MERGED $LOCAL $BASE $REMOTE
trustexitcode = false
[difftool "sgdm"]
cmd = sgdm $LOCAL $REMOTE
[mergetool "sgdm"]
trustexitcode = false
cmd = sgdm --merge --result=$MERGED $LOCAL $MERGED $REMOTE --title1=Mine --title2='Merged: $MERGED' --title3=Theirs
答案 2 :(得分:2)
This为我工作:
C:\> git config --global diff.tool diffmerge
C:\> git config --global difftool.diffmerge.cmd
"C:/Program\ Files/SourceGear/Common/DiffMerge/sgdm.exe
\"$LOCAL\" \"$REMOTE\""
C:\> git config --global merge.tool diffmerge
C:\> git config --global mergetool.diffmerge.trustExitCode true
C:\> git config --global mergetool.diffmerge.cmd
"C:/Program\ Files/SourceGear/Common/DiffMerge/sgdm.exe
/merge /result=\"$MERGED\" \"$LOCAL\" \"$BASE\" \"$REMOTE\""
答案 3 :(得分:1)
以下为我工作 -
git config --global diff.tool diffmerge git config --global difftool.diffmerge.cmd 'C:/Program\ Files/SourceGear/Common/DiffMerge/sgdm.exe "$LOCAL" "$REMOTE"' git config --global merge.tool diffmerge git config --global mergetool.diffmerge.trustExitCode true git config --global mergetool.diffmerge.cmd 'C:/Program\ Files/SourceGear/Common/DiffMerge/sgdm.exe -merge -result="$MERGED" "$LOCAL" "$BASE" "$REMOTE"'
答案 4 :(得分:0)
此配置适用于Git 1.7.9和Windows 7 64位。我的出发点是Pro Git书http://git-scm.com/book/en/Customizing-Git-Git-Configuration。对Windows和Mac的更改是a)对于diff,只是替换/用\\并且在包含空格的路径周围放置引号b)用于合并参数与您的相同但是带引号。因此:
<强>的.gitconfig 强>
[merge]
tool = extMerge
[mergetool "extMerge"]
cmd = extMerge "$BASE" "$LOCAL" "$REMOTE" "$MERGED"
trustExitCode = false
[diff]
external = extDiff
PATH上的两个脚本文件
<强> extMerge 强>
#!/bin/sh
"C:\\Program Files\\SourceGear\\Common\\DiffMerge\\sgdm.exe" "-merge" "-result=$4" "$2" "$1" "$3"
<强> extDiff 强>
#!/bin/sh
[ $# -eq 7 ] && "C:\\Program Files\\SourceGear\\Common\\DiffMerge\\sgdm.exe" "$2" "$5"
答案 5 :(得分:0)
当其他人没有做到时,这个人为我做了:
[core]
autocrlf = false
[user]
email = XYZ
name = ABC
[merge]
tool = diffmerge
[mergetool "diffmerge"]
trustExitCode = true
cmd = C:/Program\\ Files/SourceGear/Common/DiffMerge/sgdm.exe --merge --result=$MERGED $LOCAL $BASE $REMOTE
[mergetool]
keepBackup = false
[difftool "diffmerge"]
cmd = C:/Program\\ Files/SourceGear/Common/DiffMerge/sgdm.exe \"$LOCAL\" \"$REMOTE\"
[diff]
tool = diffmerge
[push]
default = matching