After installing Windows 7 I had trouble getting git diff
to work properly with diffmerge. In fact, any external tool I tried to define would hang PowerShell once it exited. Unfortunately in the time I had to look at it I couldn’t figure out if this was due to a new version of PowerShell with Windows 7, the new version of MSys Git I had installed, or something strange after switching to x64 architecture. What I did have time for was to find a workaround using git difftool
, which is a new command added to Git as of version 1.6.3.
The workaround is essential just a tweak of the steps we used previously to get git diff
working, so its probably easiest to have a quick skim through that before going through this.
Configuration tweaks
First alteration to the previous approach was to create a difftool wrapper for Diffmerge. I called this git-diff-diffmerge-wrapper.sh
and put it in my Git/cmd
directory (which is also on my PATH).
#!/bin/sh "C:/Program Files (x86)/SourceGear/DiffMerge/DiffMerge.exe" "$1" "$2" | cat
Next step was to update .gitconfig
to disable the previously added external tool setup for git diff
, and configure git difftool
in its place.
[diff] #external = git-diff-wrapper.sh tool = diffmerge [difftool "diffmerge"] cmd = git-diff-diffmerge-wrapper.sh "$LOCAL" "$REMOTE" # ... snipping rest of .gitconfig ... #
I’ve left the external tool commented out (prefixed by #). This syntax is more in line with the way the we configured the git mergetool
last time.
Using git difftool
Now whenever we type git diff
we will get the standard, textual git difference listing. If we want to use the externally configured tool, we need to type git difftool
(followed by the usual range of diff options) and follow the prompts instead. I actually like having the ability to switch between a quick diff and firing up an external tool. With this approach we can also configure multiple diff tools and pick whichever one is our favourite at the moment (or just try out a new diff tool). The command also closely parallels that used to bring up an external tool for merging (git mergetool
).
I wish I knew what caused my original issue, but at least I’ve got my graphical diff tools back for Git. :)