问题
In keeping with a number of solutions posted on the internet I have installed KDiff3 and modified .gitconfig
as below to make use of it. Nonetheless, when I run git diff HEAD^ HEAD
within a repository to test it I get a diff performed by the default tool. I'm running cygwin git on Windows7-64. Can anyone explain why KDiff3 is not invoked?
[diff]
tool = kdiff3
[merge]
tool = kdiff3
[difftool "kdiff3"]
path = \"D:/Program Files (x86)/KDiff3/kdiff3.exe\"
keepBackup = false
trustExitCode = false
[mergetool "kdiff3"]
path = \"D:/Program Files (x86)/KDiff3/kdiff3.exe\"
keepBackup = false
trustExitCode = false
回答1:
Use git difftool
to invoke the configured diff tool, not git diff
.
Since you seem to be using cygwin git, but a native kdiff3, you'll probably also need to invoke a wrapper script, rather than kdiff3 directly, to use cygpath
convert paths from cygwin form to native form.
回答2:
Actually, the wrapper script is not needed. If kdiff3.exe is not in your path, you need to give the full path in cmd as cmd = /cygdrive/c/apps/KDiff3/kdiff3 ...
My .gitconfit
[diff]
tool = kdiff3
[merge]
tool = kdiff3
[difftool "kdiff3"]
cmd = kdiff3 \"$(cygpath -wla $LOCAL)\" \"$(cygpath -wla $REMOTE)\"
trustExitCode = false
[mergetool "kdiff3"]
cmd = kdiff3 \"$(cygpath -wla $BASE)\" \"$(cygpath -wla $LOCAL)\" \"$(cygpath -wla $REMOTE)\" -o \"$(cygpath -wla $MERGED)\"
keepBackup = false
trustExitCode = false
[mergetool]
prompt = false
[difftool]
prompt = false
回答3:
git config --global merge.tool kdiff3
git config --global mergetool.kdiff3.path "C:/Program Files/KDiff3/kdiff3.exe"
git config --global mergetool.kdiff3.keepbackup=false
git config --global mergetool.kdiff3.trustexitcode=false
please check config : git config --global -l
this work fine on cywin 64bit
来源:https://stackoverflow.com/questions/15097053/kdiff3-under-cygwin-git-will-not-invoke