gpt4 book ai didi

git - 'git diff' 可以只输出长行中的更改吗?

转载 作者:行者123 更新时间:2023-12-04 01:11:19 26 4
gpt4 key购买 nike

当我对仅包含一个很长行的文件进行更改时,可以 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 andextending to the end of the line. Newlines in the input are represented bya 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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com