'git diff' 可以只输出长行中的更改吗?
Can 'git diff' output only the changes from within long lines?
当我对一个只包含很长一行的文件进行更改时,能否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 diff
只输出更改的那部分行?
我知道 git diff --word-diff
只会用颜色突出显示已更改的部分,但它仍会输出整行。
是否可以选择只输出行中发生变化的部分?或者也许是一个只能匹配 git diff --word-diff
?
是,使用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
~
否则您可以搜索 [-
和 {+
。