我可以让git add -p显示像git diff --word-diff一样的变化吗? [英] Can I make git add -p show changes like git diff --word-diff?
问题描述
我在我的代码库中递归地替换了许多单个字模式。在提交之前,我需要检查每个错误的替换。如果 git add -p
使用 - word-diff
使用的格式,这对我有很大帮助 git diff
,其中只有被修改的单词被标记出来,而不是整行。
有人问过这里,但也许它自从实施?
https://groups.google.com/forum/# !topic / git-users / 7u02OUJGvP0
由于Git 2.9可以使用属性
interactive.diffFilter
(正如我在下面这个答案所提到的那样)所以至少尝试一下: git -c interactive.diffFilter =git diff --color-wordsadd -p
code>
git -c interactive.diffFilter =git diff --word-diffadd -p
I have recursively replaced many single word patterns in my code base. Before committing I need to check each for false replacements. It would help me a lot to have git add -p
use the format of what --word-diff
uses with git diff
, where only the changed words are marked and not the entire line.
Someone has asked the same here, but maybe it was implemented since? https://groups.google.com/forum/#!topic/git-users/7uO2OUJGvP0
Since Git 2.9, you can use the property interactive.diffFilter
(as I mentioned below this answer)
So try at least:
git -c interactive.diffFilter="git diff --color-words" add -p
git -c interactive.diffFilter="git diff --word-diff" add -p
这篇关于我可以让git add -p显示像git diff --word-diff一样的变化吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!