`git add --patch` with `--word-diff`

让人想犯罪 __ 提交于 2019-12-21 07:58:06

问题


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.)


回答1:


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!