In this little recipe, we’re going to teach git on Windows how to run our own custom diff tool when we execute
git difftool. The diff tool I’m using is WinMerge.
We’ll need to enter a few new configuration options on the command line:
git config --global diff.tool winmerge git config --global difftool.winmerge.cmd "C:/git-difftool.bat \"$LOCAL\" \"$REMOTE\"" git config --global difftool.prompt false
Then create your wrapper script at
C:/git-difftool.bat. Git will call this script when executing
git difftool. That script should look like:
"C:/Program Files (x86)/WinMerge/WinMergeU.exe" -e -ub "$1" "$2"
Yes, this is using bash syntax in Windows shell! It works thanks to git, so you can execute
git difftool from either the git shell or from Windows shell.
NOTE: backslashes won’t work in regular widows shell, but WILL in git shell — I know, weird! 🙂
There you are! Now you can enjoy git on Windows (ok, just kidding) AND on Linux!