gpt4 book ai didi

git - 如何排除带有 "git diff"的补丁 header ?

转载 作者:太空狗 更新时间:2023-10-29 12:59:34 24 4
gpt4 key购买 nike

例如在 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 差异 | tail -n +5 将产生您想要的输出。

我们将 git diff 的输出通过管道传输到 tail -n +5 以在第 5 行开始输出。参见 man 页面 尾-n:

   -n, --lines=[+]NUM
output the last NUM lines, instead of the last 10; or use -n
+NUM to output starting with line NUM

如果您想要 merge --- a/commands.txt+++ b/commands.txt,您将不得不做一些额外的正则表达式工作> 到单行。

关于git - 如何排除带有 "git diff"的补丁 header ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47496283/

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