git show 显示 commit 提交说明信息

一、只显示某个 commit 的内容

示例:
1.有多次提交记录。
image



2.只显示 8dd428 这个 commit 的 log

git show 8dd428

image


3.加上 --name-only 参数,只显示文件名,不显示对比差异信息

git show --name-only 8dd428

image


4.加上 --data 设置日期显示方式。
--date 更详细用法 --> git --date时间显示设置格式命令

git show a19f176 --name-only --date=format:%c

// %c 以系统区域设置的首选格式显示日期

image


5.只显示 提交的文件名( 不显示文件移动目录的 => )

## 只显示 文件名
git show --pretty="format:" --name-only c390232f
## 显示所以提交的文件名
git log c390232f --pretty="format:" --name-only

效果:
image


6.git show 不显示文件是否移动目录的 => git log 会显示文件是否被移动过

差异注意: 有些时候就是想要知道 文件是否被移动的


示例(1)

文本:

qt@qt-vm:~/git-test$ git log --stat -1
commit 7c10699603efd6761ae4e7d7a7af1ad25b386ca5 (HEAD -> n)
Author: t <t@test.com>
Date: Wed Jun 28 11:56:50 2023 +0800
t1.txt 移动目录
t1.txt => his/t1.txt | 0
1 file changed, 0 insertions(+), 0 deletions(-)
qt@qt-vm:~/git-test$
qt@qt-vm:~/git-test$ git show -1
commit 7c10699603efd6761ae4e7d7a7af1ad25b386ca5 (HEAD -> n)
Author: t <t@test.com>
Date: Wed Jun 28 11:56:50 2023 +0800
t1.txt 移动目录
diff --git a/t1.txt b/his/t1.txt
similarity index 100%
rename from t1.txt
rename to his/t1.txt
qt@qt-vm:~/git-test$

截图:
image


示例(2):
更简洁显示文本:

qt@qt-vm:~/git-test$ git log --stat --pretty="format:" -1
t1.txt => his/t1.txt | 0
1 file changed, 0 insertions(+), 0 deletions(-)
qt@qt-vm:~/git-test$
qt@qt-vm:~/git-test$
qt@qt-vm:~/git-test$ git show --pretty="format:" --name-only -1 his/t1.txt
qt@qt-vm:~/git-test$

更简洁显示截图:
image



二、查看指定commit id对应修改文件列表


示例:

git show --raw commit_id

演示:

git show --raw 9446e75cfa5800e1f1d14ec1651662b45341d935
git show --raw 9446e7

效果:
image



参考:
https://www.cnblogs.com/wutou/p/17490984.html



posted @   悟透  阅读(890)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· .NET10 - 预览版1新功能体验(一)
点击右上角即可分享
微信分享提示