Git - 日志

记录常用的日志查询方式及格式

git log

bash 复制代码
commit <commitID>
Author: <user><<email>>
Date:   <time>

    <info>

    Change-Id: <changeID>

git log -p

bash 复制代码
# 在 git log 的基础上追加补丁信息
diff --git <file> <file>
index 54f466c..292b0df 100755
--- <file>
+++ <file>
@@ -252,7 +252,7 @@
         .............

git log --stat

bash 复制代码
# 在 git log 的基础上追加各个文件修改行信息
<file> | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

# 不携带具体文件信息
--shortstat
1 file changed, 1 insertion(+), 1 deletion(-)

git log --name-only

bash 复制代码
# 在 git log 的基础上追加修改的文件
<file>

# 携带文件修改状态
--name-status
M       <file>

git log --pretty=<>

bash 复制代码
oneline == git log --oneline, 只有 commit(短) msg
medium     默认
short      比默认少 Date 和 Change-Id, 即,只有 commit Author msg
full       比默认多 Commit Merge, 少 Date
fuller     比full多 AuthorDate CommitDate
email
  From <commitID> <time>
  From: <user> <<email>>
  Date: <time>
  Subject: [PATCH] <info>

  Change-Id: <changeID>
raw        比默认多 tree parent committer, 少 Date
format:
  %H  显示hash
  %h  提交对象的简短哈希字串
  %T  树对象(tree)的完整哈希字串
  %t  树对象的简短哈希字串
  %P  显示父节点hash
  %p  父对象的简短哈希字串
  %ad 显示作者时间 Mon May 15 09:40:07 2023 +0800
  %cd 显示提交时间 Mon May 15 09:40:07 2023 +0800
    --date=format:%Y-%m-%d %H:%M:%S 指定时间显示格式
  %ae 显示作者邮箱
  %ce 显示提交者邮箱
  %an 作者(author)的名字
  %cn 提交者(committer)的名字
  %ar 作者修订日期,按多久以前的方式显示
  %cr 提交日期,按多久以前的方式显示
  %s  显示主题
  %b  显示内容

git log --date=<>

bash 复制代码
relative == git log --relative-date
local       本地时间
iso         ISO 8601 format
rfc         RFC 2822 format
short       YYYY-MM-DD format
raw         %s %z format
format
  %a:星期缩写, Tue
  %A:星期全称, Tuesday
  %b:月份缩写, Jul
  %B:月份全称, July
  %c:时间全称, Tue 04 Jul 2023 02:24:58 PM GMT
  %d:日期 (01 -- 31), 04
  %H:小时 (00 -- 23), 14
  %I:小时 (01 -- 12), 02
  %j:一年中第几天 (001 -- 366), 185
  %m:月份 (01 -- 12), 07
  %M:分钟 (00 -- 59), 27
  %p:上午下午, AM/PM
  %S:秒数 (00 -- 59), 58
  %U:一年中的第几周,周日为一周的开始 (00 -- 53), 27
  %w:星期编号 (0 -- 6; 周日 is 0), 2
  %W:一年中的第几周,周以为一周的开始 (00 -- 53), 27
  %x:本时区的日期, 07/04/2023
  %X:本时区的时间, 02:24:58 PM
  %y:2位年份 (00 -- 99), 23
  %Y:4位年份, 2023
  %z, %Z:时区编号和时区名称缩写, +0000 GMT
  %%:Percent sign

其他参数

bash 复制代码
# 显示7位commit
--abbrev-commit

# 显示提交时间与当前时间差
--relative-date

# 显示 graph 信息
--graph

显示数量

bash 复制代码
-n          显示前n条
--after     在之后
--until     结束时间
--before    在之前
--since     开始时间
--author    作者
--grep      内容
--          文件
<br>        分支
--branches  所有分支,只是本地的所有分支
--no-merges 忽略合并的提交,两个分支合并代码时可能出现两个父节点的节点,该节点就是合并的提交,同理还有--merges参数
相关推荐
Zach_yuan3 小时前
版本控制器Git
linux·git
唐青枫8 小时前
Git 提交时神秘的 create mode 100644 到底是什么?一文告诉你答案!
git
春生野草8 小时前
Git-git stash与分支管理
git
ljh5746491198 小时前
Git合并冲突解决方法
git
悟能不能悟8 小时前
git revert commit和undo commit的区别
git
222you20 小时前
Git的diff命令
git
补三补四1 天前
Git 基础操作指南
大数据·git·elasticsearch
222you1 天前
git的命令
git
Coolbike1 天前
Git工作流
git
~央千澈~1 天前
实战针对本地项目git如何移除旧仓库关联并且添加关联新仓库-优雅草卓伊凡
git