Setting diffmerge as visual Git difftool not worki

2020-06-24 01:40发布

问题:

I am trying to configure DiffMerge as my difftool in Git but having no luck. This is the revelent section of my .gitconfig file (the other settings not shown are just for the user).

[diff]
        tool = diffmerge
[difftool "diffmerge"]
        cmd = \"C:\\Program Files\\SourceGear\\Common\\DiffMerge\\sgdm.exe\" \"$LOCAL\" \"$REMOTE\"

Whenever I call git difftool from the powershell command line the conflicts are shown directly beneath in the powershell interface, not in diffmerge as intended. I know the settings are being picked up by git because when I inspect the global config I am given the settings from the config file:

git config --global --get-all difftool.diffmerge.cmd
"C:\Program Files\SourceGear\Common\DiffMerge\sgdm.exe" "$LOCAL" "$REMOTE"

I am running powershell and not git bash. This is because I installed github for windows which provided powershell as the shell for git so I have not needed to install bash (yet). Git version is 1.7.11.msysgit.0.

回答1:

I was getting mixed up with difftool and mergetool. I needed to be use mergetool to resolve conflicts with a visual inteface and save the results. difftool only shows you the differences. See git-mergetool-vs-difftool for clarification.

I added this section to my .gitconfig and called git mergetool from the powershell command line instead. Happy days.

[merge]
    tool = diffmerge
[mergetool "diffmerge"]
    cmd = \"C:\\Program Files\\SourceGear\\Common\\DiffMerge\\sgdm.exe\" --merge --result=\"$MERGED\" \"$LOCAL\" \"$BASE\" \"$REMOTE\"
    trustExitCode = true
    keepBackup = false