如果我已经有了提交的哈希值,并且需要知道在这次提交中添加了哪些文件、修改了哪些文件以及删除了哪些文件,我该怎么办?
让我具体说一下。commit 中6128373,added1.txt新增、modified.txt修改、deleted.txt删除。
我尝试过git show ,输出如下。它确实有我想要的,但有太多不需要的细节,比如线与线之间的差异。
$ git show 6128373
commit 61283738b68b3e9e8d06dc5b9fdb722a43fe33cb (HEAD -> master)
Date: Wed Jun 23 17:35:17 2021 +0800
add modify delete
diff --git a/added1.txt b/added1.txt
new file mode 100644
index 0000000..53bf775
--- /dev/null
+++ b/added1.txt
@@ -0,0 +1 @@
+added
\ No newline at end of file
diff --git a/deleted.txt b/deleted.txt
deleted file mode 100644
index e69de29..0000000
diff --git a/modified.txt b/modified.txt
index d8263ee..1234e84 100644
--- a/modified.txt
+++ b/modified.txt
@@ -1 +1,2 @@
-2
\ No newline at end of file
+2
+3
\ No newline at end of file
Run Code Online (Sandbox Code Playgroud)
我尝试过git log 6128373,输出如下。它没有我想要的,并且显示了我不关心的提交。
commit 61283738b68b3e9e8d06dc5b9fdb722a43fe33cb (HEAD -> master)
Author:
Date: Wed Jun 23 17:35:17 2021 +0800
add modify delete
commit 044e02554997346accf215b3c8022e15751973d9
Author:
Date: Wed Jun 23 17:34:42 2021 +0800
a
...
...
Run Code Online (Sandbox Code Playgroud)
我试过
$ git diff --name-only 6128373~ 6128373
added1.txt
deleted.txt
modified.txt
Run Code Online (Sandbox Code Playgroud)
并且它不显示添加|删除|修改了哪些文件
我认为你缺少包含--name-status选项
参考:https://git-scm.com/docs/git-show#Documentation/git-show.txt---name-status
--name-status
仅显示已更改文件的名称和状态。请参阅 --diff-filter 选项的说明,了解状态字母的含义。就像 --name-only 一样,文件名通常以 UTF-8 编码。
例子
git show --name-status <commitID>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
215 次 |
| 最近记录: |