git log 单行、多行 详细显示结果、提交的文件名【汇总参数演示】
git显示 commit id 有很多样式
git log -xx --xxxx 参数【汇总】: https://www.cnblogs.com/wutou/p/17581606.html
一. 单行显示 log [注]
1 | git log --pretty=oneline |
注:
--pretty
:使用其他格式显示历史提交信息。可用的选项包括oneline
、short
、full
、fuller
和format
(用来定义自己的格式)。[注]
效果:
提交一个多行说明
打印结果
二.显示详细 log
可以显示详细修改了哪些文件
1 | git log --stat |
效果:
三.只显示ID 和 提交说明
1 | git log |
效果:
四.只显示最后一个提交的 log[注]
有多次提交记录:
只显示最后一个:
1 | git log -1 // -减号后是数字 |
五. 查看指定author在指定时间修改信息
1 | $ git log --pretty= "%h - %s" --author= 'Junio C Hamano' --since= "2008-10-01" --before= "2008-11-01" --no-merges -- t/ |
效果:
5610e3b - Fix testcase failure when extended attributes are in use
acd3b9e - Enhance hold_lock_file_for_{update,append}() API
f563754 - demonstrate breakage of detached checkout with symbolic link HEAD
d1a43f2 - reset --hard/read-tree --reset -u: remove unmerged new paths
51a94af - Fix "checkout --track -b newbranch" on detached HEAD
b0ad11e - pull: allow "git pull origin $something:$current_branch" into an unborn branch
六.git log --stat 长路径显示 ...(省略号)
假设有以下路径:将 txt 文件,移动了路径。
1 2 | cd homehome /nginxnginx/tomcattomcat/web/ mv test - test - test -testa.txt www /xx2 |
在 git 提交后:部分路径被隐藏了。
解决方法:
方式一:把终端框拉大。
方式二:给 --stat 设置显示字符数 [注]
1 | git log --stat=200 -1 |
截图:
七、按图表,画出一个ASCII图展示commit历史的分支结构
1 | $ git log --graph --oneline --decorate |
不加 --oneline 参数
十一、git log --pretty= 的参数:
使用其他格式显示历史提交信息。可用的选项包括 oneline、short、full、fuller 和 format(用来定义自己的格式)。
1.普通显示:
2. git log -1 --pretty=oneline
git log --oneline
3. git log -1 --pretty=short
4. git log -1 --pretty=full
5. git log -1 --pretty=fuller
6. git log -1 --pretty="format:%s"
%s ,参看附录一
7. git log commit 提交说明原样输出
从 log 第5行取内容,取出说明行开头的空格。[注]
1 2 3 | git log -1 >git-log.txt cat git-log.txt | tail -n +5 | sed 's/^[ \t]*//g' >git-log-tmp.txt cat git-log-tmp.txt |
截图:
8. git log 只显示提交说明内容,支持回车换行 [注]
1 2 3 | git log -- format = "%B" -n 1 fc72384998810cdaa0ac8fafb45ae30e78af563f 或 git log -- format = "%B" -n 1 |
-n 1 和 -1 是相同效果,只显示最近的1次提交说明
效果:
注: 经测试,%B 获取的提交说明保存到文件后,用 -F 文件名 再次读取文件时,新 commit 里不会多出空行。
附录 一:
最新参数:https://www.cnblogs.com/wutou/p/17538388.html
--pretty=format 常用选项 [注]
选项 | 说明 | 速记 |
---|---|---|
%H | 提交的完整哈希值 | commit hash |
%h | 提交的简写哈希值 | Abbreviated commit hash |
%T | 树的完整哈希值 | tree hash |
%t | 树的简写哈希值 | Abbreviated tree hash |
%P | 父提交的完整哈希值 | Parent hashes |
%p | 父提交的简写哈希值 | Abbreviated parent hashes |
%an | 作者名字 | author name |
%ae | 作者的电子邮件地址 | author email |
%ad | 作者修订日期 | author date |
%ar | 作者修订日期,按多久以前的方式显示 | author date, relative |
%cn | 提交者的名字 | committer name |
%ce | 提交者的电子邮件地址 | committer email |
%cd | 提交日期 | committer date |
%cr | 提交日期,按多久以前的方式显示 | committer date, relative |
%s | 提交说明 | subject |
----
来源:
https://www.cnblogs.com/wutou/p/17622253.html (git 相关优秀【网站链接】)
https://www.cnblogs.com/helloworldmybokeyuan/p/11842721.html
https://git-scm.com/book/zh/v2/Git-基础-查看提交历史#pretty_format (git 官方 book 说明大全,中文版)
https://git-scm.com/book/en/v2/Git-Basics-Viewing-the-Commit-History (git 官方 book 说明大全,英文版)
https://git-scm.com/docs (git 官方 docs 说明大全,英文版)
http://static.kancloud.cn/apachecn/git-doc-zh/ (看云-Git中文参考)
https://www.cnblogs.com/lh03061238/p/16937370.html
https://www.jianshu.com/p/efff46d60986
https://code-examples.net/zh-CN/q/d8c9b6
https://blog.csdn.net/LENOVOJXN/article/details/113814940 ( git log 详细参数)
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· .NET10 - 预览版1新功能体验(一)
2022-06-19 VC++6.0新导入类和变量关联