git log 常用占位符总结
2016年11月10日
此处的占位符是指git log --pretty=format:""双引号中的占位符
| 占位符 | 说明 |
|---|---|
| %H | commit hash |
| %h | 简短 commit hash |
| %T | tree hash |
| %t | 简短的 tree hash |
| %P | parent hash |
| %p | 简短的 parent hash |
| %an | 作者名字 |
| %ae | 作者邮箱 |
| %ad | 日期,--date= 指定的格式 |
| %aD | 日期,RFC2822格式 |
| %ar | 日期,相对格式 |
| %at | 日期,Unix timestamp |
| %ai | 日期,ISO 8601格式 |
| %cn | 提交者名字 |
| %ce | 提交者邮箱 |
| %cd | 提交日期,--date= 指定的格式 |
| %cD | 提交日期,RFC2822格式 |
| %cr | 提交日期,相对格式 |
| %ct | 提交日期,Unix timestamp |
| %ci | 提交日期,ISO 8601格式 |
| %d | ref 名称,(branch、tag) |
| %s | commit 信息标题 |
| %b | commit 信息内容 |
| %Cred | 切换到红色 |
| %Cgreen | 切换到绿色 |
| %Cblue | 切换到蓝色 |
| %Creset | 重置颜色 |
| %C(…) | 自定义颜色 |
| %n | 换行 |
可以利用上面这些占位符定制一个好看 log,添加一个 alias。
我的 alias: git config --global alias.lgb "log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cd) %C(bold blue)<%an :: %ae>%Creset%n' --abbrev-commit --date=relative --branches"
