我找到了默认的漂亮格式,所以我用以下方法简化了版本:
[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
,我实际上更愿意使用medium
或fuller
格式。 / p>
是否可以仅设置git log
的格式?也许可以使用format.pretty
以外的其他选项。
一个明显的解决方案是使用 other 格式为log
或show
的版本创建别名,但我宁愿避免这种情况。
答案 0 :(得分:1)
考虑到git config format.pretty
和 git log
(configuration)的git show
总是 ,我一直为git log定义一个别名。
例如:
因此,在这种情况下,别名仍可能是当前建议的解决方法。