当前位置:   article > 正文

git log 命令详解_git log命令详解

git log命令详解

测试仓库 asdf

常用参数

  • 查询指定目录 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=<pattern>

  • 图形方式显示git log --graph

  • 一行简化展示git log --oneline

  • 排除合并提交 git log --no-merges

  • 输出内容变更量统计git log --stat <file>

  • 输出变更内容git log -p <file>

  • 自定义formatgit log --pretty=format:"<format>" | git log --format="<format>"

    参数注解
    %Hcommit 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)
    %scommit信息标题
    %C(…)设置颜色 %Cred %Cgreen %Cblue %Creset %C(yellow)
    %x00print 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"
在这里插入图片描述

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家自动化/article/detail/532420
推荐阅读
相关标签
  

闽ICP备14008679号