git log 个性化

命令如下:

git log --pretty=format:"%h"

其中format可为如下值:

*   %H: commit hash
*   %h: 缩短的commit hash
*   %T: tree hash
*   %t: 缩短的 tree hash
*   %P: parent hashes
*   %p: 缩短的 parent hashes
*   %an: 作者名字
*   %aN: mailmap的作者名字 (.mailmap对应,详情参照[git-shortlog(1)](http://linux.die.net/man/1/git-shortlog)或者[git-blame(1)](http://linux.die.net/man/1/git-blame))
*   %ae: 作者邮箱
*   %aE: 作者邮箱 (.mailmap对应,详情参照[git-shortlog(1)](http://linux.die.net/man/1/git-shortlog)或者[git-blame(1)](http://linux.die.net/man/1/git-blame))
*   %ad: 日期 (--date= 制定的格式)
*   %aD: 日期, RFC2822格式
*   %ar: 日期, 相对格式(1 day ago)
*   %at: 日期, UNIX timestamp
*   %ai: 日期, ISO 8601 格式
*   %cn: 提交者名字
*   %cN: 提交者名字 (.mailmap对应,详情参照[git-shortlog(1)](http://linux.die.net/man/1/git-shortlog)或者[git-blame(1)](http://linux.die.net/man/1/git-blame))
*   %ce: 提交者 email
*   %cE: 提交者 email (.mailmap对应,详情参照[git-shortlog(1)](http://linux.die.net/man/1/git-shortlog)或者[git-blame(1)](http://linux.die.net/man/1/git-blame))
*   %cd: 提交日期 (--date= 制定的格式)
*   %cD: 提交日期, RFC2822格式
*   %cr: 提交日期, 相对格式(1 day ago)
*   %ct: 提交日期, UNIX timestamp
*   %ci: 提交日期, ISO 8601 格式
*   %d: ref名称
*   %e: encoding
*   %s: commit信息标题
*   %f: sanitized subject line, suitable for a filename
*   %b: commit信息内容
*   %N: commit notes
*   %gD: reflog selector, e.g., refs/stash@{1}
*   %gd: shortened reflog selector, e.g., stash@{1}
*   %gs: reflog subject
*   %Cred: 切换到红色
*   %Cgreen: 切换到绿色
*   %Cblue: 切换到蓝色
*   %Creset: 重设颜色
*   %C(...): 制定颜色, as described in color.branch.* config option
*   %m: left, right or boundary mark
*   %n: 换行
*   %%: a raw %
*   %x00: print a byte from a hex code
*   %w([[,[,]]]): switch line wrapping, like the -w option of git-shortlog(1).

如果你自己定制了一个喜欢的输出方案,可以保存到git config,或者设置alias以便日后使用。
~/.gitconfig中加入:

[alias]
    lg = log --graph 

或者运行:

git config --global alias.lg "log --graph"

最后来一个别人分享的例子,稍微有些慢,但是可以看下git log定制效果,效果很酷。。

git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr)%Creset' --abbrev-commit --date=relative

转自个性化你的 Git Log 的输出格式

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 135,773评论 19 139
  • Git使用教程:https://blog.csdn.net/tgbus18990140382/article/de...
    SkTj阅读 7,791评论 1 11
  • 他,曾向他许诺:待那繁景全盛时,吾与你共踏山川,共赏世间繁华。 ...
    一六北方水阅读 1,092评论 0 0
  • 1、首次接触的喜好话术:关联与赞美 陌生环境--心理紧张而戒备--消除戒备--建立信任与喜好 沟通第一阶段:建立喜...
    简单做事阅读 2,338评论 0 3
  • 日日夜夜拉长的影子里 记忆的眼睛狡黠清醒 望向不停止穿行其中的你 敏感是浆洗过的白色布匹 粗粝,僵硬,纯粹 如离别...
    格子的图阅读 2,472评论 0 0