为git日志设置漂亮的格式

时间:2019-11-16 15:31:25

标签: git

我找到了默认的漂亮格式,所以我用以下方法简化了版本:

[format]
    pretty = %C(yellow)commit:   %h%Creset%C(auto)%d%C(reset)%nauthor:   %an <%ae>%ndate:     %ad%nsummary:  %s%n

产生类似:

commit:   ab6cdf4 (HEAD -> master, tag: v1.1)
author:   author name <author@email.com>
date:     Fri Nov 15 22:00:00 2019 +0100
summary:  A very nice commit title

第一行的颜色与往常一样。

但是,这不仅会影响git log,还会影响git show,对于git show,我实际上更愿意使用mediumfuller格式。 / p>

是否可以仅设置git log的格式?也许可以使用format.pretty以外的其他选项。

一个明显的解决方案是使用 other 格式为logshow的版本创建别名,但我宁愿避免这种情况。

1 个答案:

答案 0 :(得分:1)

考虑到git config format.pretty git log (configuration)git show总是 ,我一直为git log定义一个别名。

例如:

因此,在这种情况下,别名仍可能是当前建议的解决方法。