例如在下面的git diff
输出中
diff --git a/commands.txt b/commands.txt
index 79e881a..a9588e5 100644
--- a/commands.txt
+++ b/commands.txt
@@ -1,3 +1,7 @@
+this is an example
+abcxyz
+helllo
+wooo
makeFilePermissionExecutable
makeOwnedByMyself
makeFilePermissionEverything
是否可以 stash 以下内容:
diff --git a/commands.txt b/commands.txt
index 79e881a..a9588e5 100644
--- a/commands.txt
+++ b/commands.txt
而是只显示文件名(在这种情况下为commands.txt)?
最佳答案
git diff | tail -n +5
将产生您想要的输出。
我们将git diff
的输出传递到tail -n +5
中,以在第5行开始输出。有关man
的信息,请参见tail -n
页面:
-n, --lines=[+]NUM
output the last NUM lines, instead of the last 10; or use -n
+NUM to output starting with line NUM
如果要将
--- a/commands.txt
和+++ b/commands.txt
merge 为一行,则必须进行一些其他正则表达式工作。关于git - 如何使用 "git diff"排除补丁标题?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/47496283/