git add --patch和--word-diff [英] `git add --patch` with `--word-diff`
问题描述
git add --patch
提供了一个很好的界面,用于查看未进行的更改,然后仅暂存下一次提交中需要的更改.
git add --patch
provides a great interface for reviewing unstaged changes and then staging only the ones that are wanted in the next commit.
好,除了一件事:没有明显的方法来选择要使用哪个diff
视图.
Great, except for one thing: there is no obvious way to choose which diff
view to use.
特别是,我希望能够配置git add --patch
以与git diff --word-diff
相同的方式向我显示差异.
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.
我该如何实现?
(注意,--word-diff
和--word-diff --color
都不与--color-words
完全相同,因此此问题(及其答案)不同于此问题及其答案.但是,该问题的答案比该问题的答案要全面得多,因此,该地方可能是有关如何实现类似这样的事情的更多信息的地方."
(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
但是,Git向您显示的内容以及由于交互式命令而实际上演的内容不一定会匹配.
However, what Git shows you, and what will actually be staged as a result of your interactive commands, will not necessarily match.
这篇关于git add --patch和--word-diff的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!