网站首页 > 精选文章 正文
使用 git log 命令查看提交记录时,默认打印commit hash值、作者、提交日期、和提交信息。如果想要查看更多内容,可以提供不同的参数来指定查看的信息。具体实例说明如下。
在git log中显示committer信息
git log 命令默认显示的里面只有author,没有committer,类似于下面的信息:
$ git log commit b932a847f564c441d68fe954b19b2b275fd1e38d Author: John <john@xxxx.com> Date: Mon Oct 21 16:18:09 2019 +0800 hello release
如果要显示committer的信息,可以使用 --pretty=full 选项。例如下面显示的信息:
$ git log --pretty=full commit b932a847f564c441d68fe954b19b2b275fd1e38d Author: John <john@xxxx.com> Commit: John <john@xxxx.com> hello release
查看 man git-log 对 --pretty 选项说明如下:
--pretty[=<format>], --format=<format>
Pretty-print the contents of the commit logs in a given format, where <format> can be one of oneline, short, medium, full, fuller, email, raw and format:<string>.
默认的 medium 格式样式如下:
medium commit <sha1> Author: <author> Date: <author date> <title line> <full commit message>
可以显示 committer 信息的 full 格式样式如下:
full commit <sha1> Author: <author> Commit: <committer> <title line> <full commit message>
这里的 author 和 committer 的区别是,author 是进行这个修改的人,而 committer 是把这个修改提交到git仓库的人。
一般来说,我们自己修改代码,然后执行 git commit,那么既是 author,又是 committer。
如果别人用 git format-patch 生成 git patch,在patch文件里面会包含修改者的名称和邮箱信息。例如:
From 033abaaecd9a3133cfcc028726aa37ebdbe6bff4 Mon Sep 17 00:00:00 2001 From: Jobs <jobs@xxxx.com> Date: Mon, 21 Oct 2019 16:18:09 +0800 Subject: [PATCH] hello release
我们拿到这个patch文件,用 git am 命令把patch合入本地仓库,那么 author 是这个patch文件的修改者 Jobs,而 committer 是我们自己。
只查看某个人的提交历史
使用 git log --author=<pattern> 命令来查看某个作者的提交历史。
使用 git log --committer=<pattern> 命令来查看某个提交者的提交历史。
查看 man git-log 对这两个选项的说明如下:
--author=<pattern>, --committer=<pattern>
Limit the commits output to ones with author/committer header lines that match the specified pattern (regular expression). With more than one --author=<pattern>, commits whose author matches any of the given patterns are chosen (similarly for multiple --committer=<pattern>).
即,所给的 pattern 参数可以用正则表达式来匹配特定模式。举例如下:
使用 git log --author=John 查看 John 的上库信息,如果有多个人名都带有 John,会匹配到多个人的提交历史。
使用 git log --author=john@xxxx.com 来查看 john@xxxx.com 这个邮箱的提交历史。
使用 git log --author=@xxxx.com 来查看 @xxxx.com 这个邮箱后缀的提交历史。
猜你喜欢
- 2025-01-20 将 node_modules 目录放入 Git 仓库的优点
- 2025-01-20 微软开源Scalar 提升操作巨型Git仓库的速度
- 2025-01-20 把一个 Git 仓库打包成 zip 压缩包
- 2025-01-20 不同主机迁移git仓库Gitolite
- 2025-01-20 同步GIT仓库的操作 -- fetch命令
- 2025-01-20 还在为 Git 仓库瘦身头疼?快来试试 repo-clean
- 2025-01-20 自建Git服务器 - 创建属于你自己的代码仓库,开启你的Git私服之旅
- 2025-01-20 中央仓库管理-基于工作空间和git-submodule实现共用和管理
- 2025-01-20 从零开始,小白也能学会的创建Git仓库实操
- 2025-01-20 无公网搭建私有GIT同步仓库思路
- 最近发表
- 标签列表
-
- 向日葵无法连接服务器 (32)
- git.exe (33)
- vscode更新 (34)
- dev c (33)
- git ignore命令 (32)
- gitlab提交代码步骤 (37)
- java update (36)
- vue debug (34)
- vue blur (32)
- vscode导入vue项目 (33)
- vue chart (32)
- vue cms (32)
- 大雅数据库 (34)
- 技术迭代 (37)
- 同一局域网 (33)
- github拒绝连接 (33)
- vscode php插件 (32)
- vue注释快捷键 (32)
- linux ssr (33)
- 微端服务器 (35)
- 导航猫 (32)
- 获取当前时间年月日 (33)
- stp软件 (33)
- http下载文件 (33)
- linux bt下载 (33)