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

标签 git diff git-diff

当我对仅包含一个很长行的文件进行更改时,可以 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/

相关文章:

git - 如何将两个独立的不相关的 Git 存储库 merge 为一个具有单一历史时间轴的存储库

GIT - 无法从远程存储库中删除特定分支

c++ - 应用修改多个文件的补丁

git - 一次为多个文件配置 vsdiffmerge

推送时 Git 推送失败并显示 "fatal: early EOF"但仅在一个文件上

Git稀疏 checkout 没有得到任何文件夹

macos - 管道 sed 到差异

javascript - 在网页中显示 chop 的差异

git - 如何在 vim 中并排查看多个 git diff

github - 为什么我的 Github 'Open pull request' 页面中有一条橙色线?