When I type git diff
, I want to view the output with my visual diff tool of choice (SourceGear \"diffmerge\" on Windows). How do I configure git to do this?
I've been using this bit in ~/.gitconfig
for a long time:
[diff]
external = ~/Dropbox/source/bash/git-meld
With git-meld
:
#!/bin/bash
if [ "$DISPLAY" = "" ];
then
diff $2 $5
else
meld $2 $5
fi
But now I got tired of always using meld in graphical environment, and it's not trivial to invoke the normal diff with this setup, so I switched to this:
[alias]
v = "!sh -c 'if [ $# -eq 0 ] ; then git difftool -y -t meld ; else git difftool -y $@ ; fi' -"
With this setup, things like this work:
git v
git v --staged
git v -t kompare
git v --staged -t tkdiff
And I still get to keep the good old git diff
.