When doing a git diff, sometimes I want to use a different diff tool (like, for example, cmp, or a homebrew word-diff program I have in my own bin directory).
Many diff-like programs have an option along the lines of
-D <diffprog>
to tell them to use that other diff or diff-like program instead.
I am aware of git-difftool and this question, but that's not quite what I was looking for. I'd very much rather not have to configure something in advance, and the nonstandard command I want to use today might not be the nonstandard command I want to use tomorrow. Ideally I'd like to be able to just do it, on a one-time basis, from the command line.
(Is it possible to configure difftool to be able to use multiple nonstandard tools not on the official list?)
If it's too much trouble to get git diff to use my choice of diff tool, I could also use something like
git cat file | mydiff - file
I know there's no such command as "git cat". But the idea here is to manually compare the repo version of the file with the local one, given a git command to simply emit the repo (or, in other circumstances, the index) version of the file. Is there any such command?
Finally, if there isn't the hypothetical git diff -D diffprog option I was asking about, and if there isn't anything like the "git cat" command I was hypothesizing, am I wrong to be wishing for them?
The integrated way in
gitto open a diff in an external viewer isgit difftool.As far as cli options go,
git difftooltakes the same arguments asgit diff, and opens the resulting diff in the external viewer.One extra useful option is
-d | --dir-diff, which will create two checkouts of your repo in a temporary directory and open the external viewer in "directory comparison mode" :As far as the choice for external tool goes :
git config diff.tool kdiff3-t | --tool:difftool.<tool>.cmdentries in your git configurationquoting the docs of the
-t|--toolsection :