查询指定目录 git -C /Users/yanlp/workspace/asdf log
限制显示提交数量 git log -n 3
限制提交人|邮箱 git log --author='Edwin Kofler' | git log --author='edwin@kofler.dev'
限制一个月内的提交git log --since=1.month.ago | git log --since=2023-09-23 | git log --since=1695398400
限制一个月之前的提交git log --until=1.month.ago | git log --until=2023-09-23 | git log --until=1695398400
关键字搜索git log --grep=
图形方式显示git log --graph
一行简化展示git log --oneline
排除合并提交 git log --no-merges
输出内容变更量统计git log --stat
输出变更内容git log -p
自定义formatgit log --pretty=format:"
参数 | 注解 |
---|---|
%H | commit hash |
%h | 简短的commit hash |
%an | 作者 |
%ae | 作者的邮箱 |
%ad | 日期 (–date= 制定的格式) git log --format="%ad" --date=format:"%Y-%m-%d %H:%M:%S" |
%ar | 日期 相对格式(2 周前) |
%at | 日期 UNIX timestamp(1694357019) |
%cn | 提交者名字 |
%ce | 提交者邮箱 |
%cd | 日期 (–date= 制定的格式) git log --format="%cd" --date=format:"%Y-%m-%d %H:%M:%S" |
%cr | 日期 相对格式(2 周前) |
%ct | 日期 UNIX timestamp(1694357019) |
%s | commit信息标题 |
%C(…) | 设置颜色 %Cred %Cgreen %Cblue %Creset %C(yellow) |
%x00 | print a byte from a hex code eg. tab%x09 |
其他 git log --help
git log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --stat
git log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset'
git log --color --format="%C(blue)%ad %Cred%h %C(yellow)%cn%x09%C(green)%s" --date=format:"%Y-%m-%d %H:%M:%S"