1. 基本语法
git log ``` - **无参数**:如果不指定任何参数,`git log`将显示所有的提交记录。 - `-p`:这个参数会展示每个提交的差异,即每个提交的具体代码更改。 - `--oneline`:这个参数将每个提交压缩成一行显示,只显示哈希值和提交信息。 - `--graph`:显示分支合并的图形化表示。 - `--decorate`:显示引用信息,如分支名和标签。 - `--all`:显示所有分支的提交记录。 - `--author="author_name"`:只显示特定作者的提交。 - `--since="date"`:显示指定日期之后的提交。 - `--until="date"`:显示指定日期之前的提交。 - `--grep="pattern"`:搜索提交信息中包含特定模式的提交。 - `-s"string"`:显示添加或删除了特定字符串的提交。 - -n: 显示最近提交的n条记录 # 1. 无参数, 显示全部 直接输入 ```bash git log
显示所有提交, 后续太长了只贴了前面几个
commit c27b530c9fb65c52056e54d5137fabd92e8389fa (head -> master, origin/master) 名单更新 commit a22db668ac8e450e1d7f7d9ab8dfc80125b79364 author: dan <danzhao@163.com> date: tue nov 5 16:10:27 2024 +0800 蜀山部组调整 commit 057204b8ce640abfd68cea686aa81d330b8ead0c author: dan <danzhao@163.com> date: tue nov 5 15:53:32 2024 +0800 删除离职 commit 485f4cbe232028a6b1859593a7aa775ae50ad9de author: dan <danzhao@163.com> date: tue nov 5 11:16:45 2024 +0800 目标更新,周期更新 ...
2. -p,显示具体更改
输入
git log -p
输出每一次的具体更改,很长…
commit c27b530c9fb65c52056e54d5137fabd92e8389fa (head -> master, origin/master) author: dan <danzhao@163.com> date: tue nov 5 16:50:16 2024 +0800 名单更新 diff --git "a/excel/\345\255\246\345\216\206_\350\264\271\346\257\224_\344\270\252\344\272\272_v4.xlsx" "b/excel/\345\255\246\345\216\206_\350\264\271\346\257\224_\344\270\252\344\272\272_v4.xlsx" index 8feb94d..199858c 100644 binary files "a/excel/\345\255\246\345\216\206_\350\264\271\346\257\224_\344\270\252\344\272\272_v4.xlsx" and "b/excel/\345\255\246\345\216\206_\350\264\271\346\257\224_\344\270\252\344\272\272_v4.xlsx" differ diff --git "a/excel/\345\255\246\345\216\206\344\270\252\344\272\272\347\233\256\346\240\207\350\277\233\345\272\246\350\241\250v3.2.xlsx" "b/excel/\345\255\246\345\216\206\344\270\252\344\272\272\347\233\256\346\240\207\350\277\233\345\272\246\350\241\250v3.2.xlsx" index b72110c..a63d564 100644 binary files "a/excel/\345\255\246\345\216\206\344\270\252\344\272\272\347\233\256\346\240\207\350\277\233\345\272\246\350\241\250v3.2.xlsx" and "b/excel/\345\255\246\345\216\206\344\270\252\344\272\272\347\233\256\346\240\207\350\277\233\345\272\246\350\241\250v3.2.xlsx" differ diff --git "a/excel/\345\255\246\345\216\206\350\277\220\350\220\245\346\212\245\350\241\250v3.xlsx" "b/excel/\345\255\246\345\216\206\350\277\220\350\220\245\346\212\245\350\241\250v3.xlsx" index 29b6ec2..438cc53 100644 binary files "a/excel/\345\255\246\345\216\206\350\277\220\350\220\245\346\212\245\350\241\250v3.xlsx" and "b/excel/\345\255\246\345\216\206\350\277\220\350\220\245\346\212\245\350\241\250v3.xlsx" differ diff --git "a/excel/\350\277\220\350\220\245\346\212\245\350\241\250v1r.xlsx" "b/excel/\350\277\220\350\220\245\346\212\245\350\241\250v1r.xlsx" index 911bf89..c7c0068 100644 binary files "a/excel/\350\277\220\350\220\245\346\212\245\350\241\250v1r.xlsx" and "b/exc: ...
3. --oneline,显示成一行
输入
git log --oneline
显示id,描述
a22db66 蜀山部组调整 057204b 删除离职 485f4cb 目标更新,周期更新 d78df83 目标更正 f09eac5 target 4293be7 月目标更新 3c18c0c 研究生订单时间调整 8a2b1c1 暂无目标 8b1c4b2 吃鸡跨月没数据问题处理 01ca59e 月份更正 d6b0b9c 更新目标,研究生高效加入胡总,去除巢湖离职人员 aa0b5d1 吃鸡更新 f830832 学历目标更新 d3cff90 研究生订单时间更新 0a33f20 chick pk update date 4560b81 费比数据切换到新数据源 4666417 吃鸡周期更新 781c5f3 吃鸡比赛更新 b7370ab 吃鸡更新成海报 0bb2fdf 规划师费比评级
4. --graph, 显示图表
git log --graph ```bash 主要是查看主分支的合并提交等等, 这个项目就我一个人所以没有分支, 看起来一条直线 ```bash | author: dan <danzhao@163.com> | date: tue nov 5 16:50:16 2024 +0800 | | 名单更新 | * commit a22db668ac8e450e1d7f7d9ab8dfc80125b79364 | author: dan <danzhao@163.com> | date: tue nov 5 16:10:27 2024 +0800 | | 蜀山部组调整 | * commit 057204b8ce640abfd68cea686aa81d330b8ead0c | author: dan <danzhao@163.com> | date: tue nov 5 15:53:32 2024 +0800 | | 删除离职 | * commit 485f4cbe232028a6b1859593a7aa775ae50ad9de | author: dan <danzhao@163.com> | date: tue nov 5 11:16:45 2024 +0800 | | 目标更新,周期更新 |
5. --decorate, 显示引用
git log --decorate
我没有创建分支, 也没有使用标签, 所以并没有什么区别…
author: dan <danzhao@163.com> date: tue nov 5 16:50:16 2024 +0800 名单更新 commit a22db668ac8e450e1d7f7d9ab8dfc80125b79364 author: dan <danzhao@163.com> date: tue nov 5 16:10:27 2024 +0800 蜀山部组调整 commit 057204b8ce640abfd68cea686aa81d330b8ead0c author: dan <danzhao@163.com> date: tue nov 5 15:53:32 2024 +0800 删除离职 ...
6. -all, 显示所有分支提交记录
我的也是没有分支, 所以没区别,略过
7. --author, 按作者筛选
git log --author='dan'
这里注意
- 两条短横线
- 只有一个等于号
- 单双引号都可以
作者会突出显示红色, 所以截图显示
8. --since, 指定日期之后的提交
git log --since='2024/11/1'
或
git log --since='2024-11-1'
正常输出
author: dan <danzhao@163.com> date: tue nov 5 16:50:16 2024 +0800 名单更新 commit a22db668ac8e450e1d7f7d9ab8dfc80125b79364 author: dan <danzhao@163.com> date: tue nov 5 16:10:27 2024 +0800 蜀山部组调整 commit 057204b8ce640abfd68cea686aa81d330b8ead0c author: dan <danzhao@163.com> date: tue nov 5 15:53:32 2024 +0800 删除离职 ...
9. --until, 和since相反
git log --unitl='2024-5-1'
正常输出
author: dan <danzhao@163.com> date: tue apr 30 15:17:54 2024 +0800 fix commit afdc076d7a202117125a6073c9da512f56bbd0db author: dan <danzhao@163.com> date: tue apr 30 15:16:12 2024 +0800 研究生无数据播报bug修正 commit 021911fb560fddfa8713d1f12585a5597950b5e2 author: dan <danzhao@163.com> date: mon apr 29 10:45:16 2024 +0800 1. 例外情况修正; 2. 开始测试ai接入 ...
10. --grep, 匹配
例如输入
git log --grep='1'
会显示我所有提交提示为1的提交记录, 红色突出显示
这个应该是最实用的提交了
11. -s, 搜索特定字符是否修改
git log -s'markdown'
慎用, 会要一点时间
commit 4560b81bdcc5c28c3434e30b11e5c7f10eeb32ba author: dan <danzhao@163.com> date: wed oct 23 17:29:59 2024 +0800 费比数据切换到新数据源 commit b1bc6bca62ec38d6b5b516789da65b8fd170896b author: dan <danzhao@163.com> date: thu sep 5 18:33:19 2024 +0800 新增研究生分地域播报发胡总 commit c1435d6439125ed9008f3aff27d2e971949ea06d author: dan <danzhao@163.com> date: wed aug 21 11:39:52 2024 +0800 新增单独发送的研究生分团队播报 ...
12. -n, 显示最近提交的几条记录
git log -3
显示最近提交的3条记录
commit c27b530c9fb65c52056e54d5137fabd92e8389fa (head -> master, origin/master) author: dan <danzhao@163.com> date: tue nov 5 16:50:16 2024 +0800 名单更新 commit a22db668ac8e450e1d7f7d9ab8dfc80125b79364 author: dan <danzhao@163.com> date: tue nov 5 16:10:27 2024 +0800 蜀山部组调整 commit 057204b8ce640abfd68cea686aa81d330b8ead0c author: dan <danzhao@163.com> date: tue nov 5 15:53:32 2024 +0800 删除离职
以上就是git如何查看历史提交及其参数设定的常用命令详解的详细内容,更多关于git查看历史提交及参数设定的资料请关注代码网其它相关文章!
发表评论