When diffing files, I prefer to use git diff --color-words. Is there a way to make this the default format for diffs when using git add --patch or
I recently solved this issue, but it requires modifying a Perl script in git. That's easy and requires no special skill, however.
This solution requires that your git configuration use colorization for screen output, because that's the only circumstance under which git will show a word-based diff.
git-add--interactive from your installation to somewhere in your PATH environment variable and rename it git-add--interactive-words.@colored = run_cmd_pipe("git", @diff_cmd, qw(--color --), $path);
to
@colored = run_cmd_pipe("git", @diff_cmd, qw(--color --color-words --), $path);
git add-interactive--words to do the equivalent of git add --interactive with colorized word-based diff.git add --patch with that is awkward because you need to pass the new script the right parameters. Fortunately, you can create an alias to the magic words in your .gitconfig:[alias]
iaddpw = add--interactive-words --patch=stage --
which means git iaddpw runs the equivalent of git add --interactive --patch with colorized word-based diff.
*- For Git 2.18, this command is:
my @display_cmd = ("git", @diff_cmd, qw(--color --), $path);