12

所以我看到了一些关于让 DiffMerge 成为gitmergetool的问题。difftool从本质上讲,它归结为在您的 DiffMerge (sgdm.exe) 中PATH.gitconfig它看起来像:

[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只有),但仍然无济于事。

有没有人遇到过这个?我缺少一些明显的东西吗?我觉得我错过了一些明显的东西。

4

6 回答 6

13

.gitconfig使用 SourceGear DiffMerge 的方法是:

[mergetool "diffmerge"]
cmd = \"C:\\program files\\sourcegear\\common\\diffmerge\\sgdm.exe\" --merge --result=$MERGED $LOCAL $BASE $REMOTE

(显然,翻转$LOCAL$REMOTE如果你更喜欢它们在另一边。)

于 2012-12-13T20:55:14.120 回答
8

以下为我工作-

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"'
于 2018-04-18T14:48:01.850 回答
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
于 2013-03-20T19:34:13.020 回答
2

对我有用:

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\""
于 2014-02-25T10:36:19.120 回答
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
于 2014-10-31T15:32:42.793 回答
0

此配置适用于 Git 1.7.9 和 Windows 7 64 位。我的出发点是 Pro Git 书籍http://git-scm.com/book/en/Customizing-Git-Git-Configuration。Windows 与 Mac 的变化是 a) 差异,只需将 / 替换为 \\ 并在包含空格的路径周围加上引号 b) 用于合并参数与您的参数相同,但带有引号。因此:

.gitconfig

[merge]
     tool = extMerge
[mergetool "extMerge"]
    cmd = extMerge "$BASE" "$LOCAL" "$REMOTE" "$MERGED"
    trustExitCode = false
[diff]
    external = extDiff

PATH 上的两个脚本文件

扩展合并

#!/bin/sh
"C:\\Program Files\\SourceGear\\Common\\DiffMerge\\sgdm.exe" "-merge" "-result=$4" "$2" "$1" "$3"

扩展差异

#!/bin/sh
[ $# -eq 7 ] && "C:\\Program Files\\SourceGear\\Common\\DiffMerge\\sgdm.exe" "$2" "$5"
于 2013-01-30T13:30:05.687 回答