git add --patch
provides a great interface for reviewing unstaged changes and then staging only the ones that are wanted in the next commit.
Great, except for one thing: there is no obvious way to choose which diff
view to use.
In particular, I would like to be able to configure git add --patch
to present diffs to me the same way that git diff --word-diff
does.
How can I achieve that?
(N.B. neither --word-diff
nor --word-diff --color
is exactly the same as --color-words
, and so this question (and its answer) are different to this question and its answers. However, that question's answers are much more comprehensive than this one's, so that is probably the place to go for more information about how to do achieve things like this.)
This is sort of possible, as follows:
git -c interactive.diffFilter="git diff --word-diff --color" add --patch
However, what Git shows you, and what will actually be staged as a result of your interactive commands, will not necessarily match.
来源:https://stackoverflow.com/questions/49058817/git-add-patch-with-word-diff