【问题标题】:Git configure difftool and mergetool by DiffMerge not workingGit 通过 DiffMerge 配置 difftool 和 mergetool 不起作用
【发布时间】:2017-10-14 15:02:29
【问题描述】:

我正在尝试为 git 配置 DiffMerge 以用于 difftool 和 mergetool。我使用了以下命令:-

命令提示符窗口中的以下命令将更新您的 .gitconfig 以配置 GIT 使用 DiffMerge:

  C:\> git config --global diff.tool diffmerge

 C:\> git config --global difftool.diffmerge.cmd

  "C:/Program\ Files/SourceGear/Common/DiffMerge/sgdm.exe \"$LOCAL\" 
  \"$REMOTE\""`

如果我检查 .gitconfig 的内容,它有以下内容:-

   ` [diff]
        tool = diffmerge
    [mergetool "diffmerge"]
        cmd = C:/Program\\ Files/SourceGear/Common/DiffMerge/sgdm.exe -merge -result=\"\" \"\" \"\" \"\"
        trustExitCode = true
    [merge]
        tool = diffmerge
    [difftool "diffmerge"]
        cmd = C:/Program\\ Files/SourceGear/Common/DiffMerge/sgdm.exe \"\" \"\"
    [core]
        autocrlf = true
        excludesfile = C:\\Users\\dev\\Documents\\gitignore_global.txt
    [user]
        name = DESKTOP - VAFJEG6\\dev
          email = madsum.isalm2@gmail.com `

如果我尝试 $ git config --global --list:-

  diff.tool=diffmerge
  mergetool.diffmerge.cmd=C:/Program\ 
  Files/SourceGear/Common/DiffMerge/sgdm.exe -merge -result="" "" "" ""
  mergetool.diffmerge.trustexitcode=true
  merge.tool=diffmerge
  difftool.diffmerge.cmd=C:/Program\ 
  Files/SourceGear/Common/DiffMerge/sgdm.exe "" ""
  core.autocrlf=true
  core.excludesfile=C:\Users\dev\Documents\gitignore_global.txt
  user.name=DESKTOP-VAFJEG6\dev
  user.email=madsum.isalm2@gmail.com`

如果我尝试 git $ git difftool 它会显示这个对话框:-

怎么了?如何正确配置?

【问题讨论】:

    标签: windows git diffmerge


    【解决方案1】:

    $LOCAL/$REMOTE mentioned in the doc 必须已由 shell 解释(如果从 git bash 而不是 CMD 会话键入)并替换为 ""

    直接编辑全局配置(git config --global --edit)并添加缺少的元素以获得:

     [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="$PWD/$MERGED" "$PWD/$LOCAL" "$PWD/$BASE" "$PWD/$REMOTE"
         trustExitCode = true
    

    【讨论】:

      猜你喜欢
      • 2017-07-06
      • 1970-01-01
      • 2016-03-11
      • 2020-12-27
      • 2017-09-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-07-20
      相关资源
      最近更新 更多