在正常的git-diff中,输出可能如下所示:
diff --git a/app/index.html b/app/index.html
index f1a34ce..723dc5c 100644
--- a/app/index.html
+++ b/app/index.html
@@ -9,6 +9,7 @@
{{content-for "head"}}
+ <link integrity="" rel="stylesheet" href="{{rootURL}}assets/tailwind.css">
<link integrity="" rel="stylesheet" href="{{rootURL}}assets/vendor.css">
<link integrity="" rel="stylesheet" href="{{rootURL}}assets/my-app.css">
有没有办法省略这个:
index f1a34ce..723dc5c 100644
--- a/app/index.html
+++ b/app/index.html
@@ -9,6 +9,7 @@
所以剩下的就是:
diff --git a/app/index.html b/app/index.html
{{content-for "head"}}
+ <link integrity="" rel="stylesheet" href="{{rootURL}}assets/tailwind.css">
<link integrity="" rel="stylesheet" href="{{rootURL}}assets/vendor.css">
<link integrity="" rel="stylesheet" href="{{rootURL}}assets/my-app.css">
这是我能想到的最好的:
git diff
| sed -n '/^---/!p'
| sed -n '/^+++/!p'
| sed -n '/^@@/!p'
| sed -n '/^index /!p'
但是有更好的方法吗?
您可以在调用git diff
时设置GIT_EXTERNAL_DIFF
环境变量,如git(1)
:中所述
当环境变量GIT_EXTERNAL_DIFF为集,则调用由其命名的程序以生成diffs,Git不使用其内置的diff机制。对于添加、删除或修改的路径,GIT_EXTERNAL_DIFF由7个参数调用:
路径旧文件旧十六进制旧模式新文件新十六进制新模式
编写一个小型shell脚本,在old-file
和new-file
之间启动您喜欢的diff
,并忽略其他参数。