Can I make git add -p show changes like git diff --word-diff?

Since Git 2.9, you can use the property interactive.diffFilter (as I mentioned below this answer)

But, any git -c interactive.diffFilter="git diff --color-words" add -p would generate, since Git 2.17, an error message

fatal: mismatched output from interactive.diffFilter

(as seen in this question)

So using a script for the interactive.diffFilter setting remains a safer way.


Adding diff-highlight to the interactive.diffFilter config key is the easiest option (since Git 2.9). The following comand does the trick on Debian/Ubuntu:

git config interactive.diffFilter "perl /usr/share/doc/git/contrib/diff-highlight/diff-highlight"

Things like git -c interactive.diffFilter="git diff --color-words" add -p or git config interactive.diffFilter "git diff --color-words" don't work properly: add -p always keeps suggesting the first modified file.