the ultimate text diffing helper
I use Git not only for code,
but also for text, my most common use case being co-authorship of
scientific papers typeset in LaTeX.
While reviewing other author changes, the usual
line-by-line diff is often annoying since:
-
Paragraph re-formatting gets in the way (hello guys accustomed
to compulsory Vim's gq or Emacs' M-q): it
does not effect the final rendering, but it still hinders
peer-review of changes.
-
Even in the simplest case of a single word change on a single
line, it will take some time for your eyes to spot where, along the
line, the actual change is.
Stuff like wdiff does help, but
I've never looked at how to integrate it with Git, and I still find
it a pain in the eyes due to the fancy ASCII arts used to denote
additions and deletions (pain that I usually experience when
looking at the output of debdiff). There are nice
diffing GUIs or editor-integrated solutions out there, but what
I've always dreamed of is a plain old cmdline geekism.
Enter Git's --color-words, that can be passed to
both show and diff commands. My favorite
related Git aliases
are as follows:
[alias]
wdiff = diff --color-words
wshow = show --color-words
Here is a sample fancy output, yet very intuitive and
console-based, of git show --color-words (text in red
denotes deletions, text in green additions):

Maybe not new to you, but it has been
life-changing for me.
|
So I had come to the conclusion that the way to integrate wdiff was to add the following to .git/config
Then you can use wdiff by calling
But I like --color-words a lot better. Thanks for the tip
"git help show doesn't mention --color-words, as of 1.6.6?"
True, it doesn't list diff-related options but only says: "The command takes options applicable to the git-diff-tree command to control how the changes the commit introduces are shown." That is, I think all the diff options are available with "git show".