【问题标题】:How to get DiffMerge configured to work with Git on Windows 7 or Windows 2012?如何将 DiffMerge 配置为在 Windows 7 或 Windows 2012 上与 Git 一起使用?
【发布时间】:2012-12-13 20:36:02
【问题描述】:

所以我看到了一些关于让 DiffMerge 成为 git 的 mergetooldifftool 的问题。本质上,它归结为在您的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 就会出现。

我已将.gitconfig 中的cmd 修改为没有路径或扩展名(例如仅sgdm),但仍然无济于事。

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

【问题讨论】:

    标签: git diffmerge


    【解决方案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"'
        

    【讨论】:

      【解决方案2】:

      这对我来说已经很长一段时间了。 (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
      

      【讨论】:

        【解决方案3】:

        我使用 SourceGear DiffMerge 的 .gitconfig 是:

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

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

        【讨论】:

        • 感谢您的回答。但是,我仍然得到相同的行为 - 没有启动,没有错误,没有。如果这很重要,我正在使用 msysgit 1.8。
        • 有趣。我正在使用 1.7.10.msysgit.1。我稍后会尝试升级,看看是否有区别。
        【解决方案4】:

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

        【讨论】:

          【解决方案5】:

          此配置适用于 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 上的两个脚本文件

          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"
          

          【讨论】:

            【解决方案6】:

            这个为我做了,而其他的都没有:

            [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
            

            【讨论】:

              猜你喜欢
              • 2010-12-20
              • 1970-01-01
              • 2017-07-06
              • 1970-01-01
              • 1970-01-01
              • 2012-04-23
              • 2018-04-10
              • 1970-01-01
              相关资源
              最近更新 更多