目录
1. git log --pretty=format:" "
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$