当我对仅包含一个很长行的文件进行更改时,可以 git diff
只输出改变的那部分行?
我知道git diff --word-diff
将仅以颜色突出显示已更改的部分,但仍会输出整行。
是否可以选择只输出已更改的那部分行?或者也许是一个只能匹配 git diff --word-diff
的彩色部分的 grep 模式?
最佳答案
是的,使用 git diff --word-diff=porcelain
.
Use a special line-based format intended for script consumption. Added/removed/unchanged runs are printed in the usual unified diff format, starting with a +/- character at the beginning of the line and extending to the end of the line. Newlines in the input are represented by a tilde ~ on a line of its own.
对长线的小改动看起来像......
~
The mouse that the cat that the dog that the
-man
+person
frightened and chased ran away
~
否则您可以搜索 [-
和 {+
.
关于git - 'git diff' 可以只输出长行中的更改吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64756140/