Git命令log详解

Git log用于查询历史版本记录,命令形式如下:

1
git log [<options>] [<since>..<until>] [[--] <path>...]

该命令有很多参数选项

alias配置

1
2
3
4
git config --global alias.lg "log --no-merges --color --graph --date=format:'%Y-%m-%d %H:%M:%S' --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Cblue %s %Cgreen(%cd) %C(bold blue)<%an>%Creset' --abbrev-commit"


git config --global alias.lgs "log --no-merges --color --stat --graph --date=format:'%Y-%m-%d %H:%M:%S' --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Cblue %s %Cgreen(%cd) %C(bold blue)<%an>%Creset' --abbrev-commit"

lg别名,显示简化信息

lgs别名,显示详细信息

参数分析

参数 含义 选项
–no-merges 过滤掉merge commit -
–color 颜色显示 -
–stat 显示每次更新的详细信息 -
–graph 显示ASCII图形表示的分支合并历史 -
–date 定制日期格式 -
–pretty 使用其他格式显示历史提交信息 oneline,short,medium,full,fuller,email,raw以及format
–abbrev-commit 仅显示SHA-1的前几个字符,而非所有的40个字符 -

版权所有,如有侵权请联系我