Git 弄懂 git log --pretty=format: “ “ 的用法

目录

1. git log --pretty=format:" "

2. 使用说明

3. 实际效果


1. git log --pretty=format:" "

官方参考:https://git-scm.com/docs/pretty-formats
控制显示的记录格式,常用的格式占位符写法及其代表的意义如下:

'%H': commit hash

'%h': abbreviated commit hash

'%t': abbreviated tree hash

'%P': parent hashes

'%p': abbreviated parent hashes

'%an': author name

'%aN': author name (respecting .mailmap, see git-shortlog or git-blame)

'%ae': author email

'%aE': author email (respecting .mailmap, see git-shortlog or git-blame)

'%ad': author date (format respects --date= option)

'%aD': author date, RFC2822 style

'%ar': author date, relative

'%at': author date, UNIX timestamp

'%ai': author date, ISO 8601-like format

'%aI': author date, strict ISO 8601 format

'%cn': committer name

'%cN': committer name (respecting .mailmap, see git-shortlog or git-blame)

'%ce': committer email

'%cE': committer email (respecting .mailmap, see git-shortlog or git-blame)

'%cd': committer date (format respects --date= option)

'%cD': committer date, RFC2822 style

'%cr': committer date, relative

'%ct': committer date, UNIX timestamp

'%ci': committer date, ISO 8601-like format

'%cI': committer date, strict ISO 8601 format

'%d': ref names, like the --decorate option of git-log

'%D': ref names without the " (", ")" wrapping.

'%e': encoding

'%s': subject

'%f': sanitized subject line, suitable for a filename

'%b': body

'%B': raw body (unwrapped subject and body)

'%N': commit notes

'%T': tree hash

'%t': abbreviated tree hash

'%P': parent hashes

'%p': abbreviated parent hashes

'%an': author name

'%aN': author name (respecting .mailmap, see git-shortlog or git-blame)

'%ae': author email

'%aE': author email (respecting .mailmap, see git-shortlog or git-blame)

'%ad': author date (format respects --date= option)

'%aD': author date, RFC2822 style

'%ar': author date, relative

'%at': author date, UNIX timestamp

'%ai': author date, ISO 8601-like format

'%aI': author date, strict ISO 8601 format

'%cn': committer name

'%cN': committer name (respecting .mailmap, see git-shortlog or git-blame)

'%ce': committer email

'%cE': committer email (respecting .mailmap, see git-shortlog or git-blame)

'%cd': committer date (format respects --date= option)

'%cD': committer date, RFC2822 style

'%cr': committer date, relative

'%ct': committer date, UNIX timestamp

'%ci': committer date, ISO 8601-like format

'%cI': committer date, strict ISO 8601 format

'%d': ref names, like the --decorate option of git-log

'%D': ref names without the " (", ")" wrapping.

'%e': encoding

'%s': subject

'%f': sanitized subject line, suitable for a filename

'%b': body

'%B': raw body (unwrapped subject and body)

'%N': commit notes

2. 使用说明

在~/…gitconfig文件中配置如下参数[alias]:

l0 = log --color --graph --decorate --pretty=oneline --abbrev-commit --date-order
l1 = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%ci) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative
l2 = log --all --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%ci) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative
l3 = log --graph --pretty=format:'%h -%d %s (%ci) <%an>' --abbrev-commit --date=relative

3. 实际效果

sean@us1404:~/demo$ git l1 -1
* 5613791 - (HEAD, master_dev) 修改升级脚本,增加是否允许相同版本升级的判断, 目前默认允许 (2020-09-28 11:07:36 +0800) <sean>
sean@us1404:~/demo$ 
sean@us1404:~/demo$ git l0 -1
* 5613791 (HEAD, master_dev) 修改升级脚本,增加是否允许相同版本升级的判断, 目前默认允许
sean@us1404:~/demo$ 
sean@us1404:~/demo$ git l1 -1
* 5613791 - (HEAD, master_dev) 修改升级脚本,增加是否允许相同版本升级的判断, 目前默认允许 (2020-09-28 11:07:36 +0800) <sean>
sean@us1404:~/demo$ 
sean@us1404:~/demo$ git l2 -1
* 5613791 - (HEAD, master_dev) 修改升级脚本,增加是否允许相同版本升级的判断, 目前默认允许 (2020-09-28 11:07:36 +0800) <sean>
sean@us1404:~/demo$ 
sean@us1404:~/demo$ git l3 -1
* 5613791 - (HEAD, master_dev) 修改升级脚本,增加是否允许相同版本升级的判断, 目前默认允许 (2020-09-28 11:07:36 +0800) <sean>
sean@us1404:~/demo$ 
  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值