如何覆盖 git 日志格式?
How to override a git log pretty format?
可用的 built-in 漂亮格式并不完全符合我的需要(或我的品味):
https://git-scm.com/docs/pretty-formats
git log --decorate --graph --all --pretty=short
几乎是我想要的,但我也希望显示提交日期...
git log --decorate --graph --all --pretty=medium
很好,但我不想要完整的提交信息。我只想显示提交消息的第一行...
所以我尝试定义我自己的漂亮格式,就像 'medium' 但没有完整的提交信息,像这样:
git log --decorate --graph --all --pretty=format:'commit %H%nAuthor: %an%nDate: %ad%n%n%s%n'
一个问题是分支名称不再显示。另一个问题是日志不再是彩色的。我怎样才能正确地做到这一点?
理想情况下,我只想 覆盖 --pretty=medium
这样它就不会显示完整的提交消息,而只显示提交的标题(或覆盖 --pretty=short
以显示日期)。这是唯一可能的吗(覆盖 built-in 漂亮的格式)?如果是,怎么做?
--decorate
不适用于自己的格式。如果你想要它,你需要使用%d
或%D
。如果你愿意,你也可以添加一些颜色来获得类似的输出,比如你可能想要这样的东西:
git log --graph --all --pretty=format:'%C(auto,yellow)commit %H%C(auto,green bold)%d%Creset%nAuthor: %an%nDate: %ad%n%n%s%n'
可用的 built-in 漂亮格式并不完全符合我的需要(或我的品味):
https://git-scm.com/docs/pretty-formats
git log --decorate --graph --all --pretty=short
几乎是我想要的,但我也希望显示提交日期...
git log --decorate --graph --all --pretty=medium
很好,但我不想要完整的提交信息。我只想显示提交消息的第一行...
所以我尝试定义我自己的漂亮格式,就像 'medium' 但没有完整的提交信息,像这样:
git log --decorate --graph --all --pretty=format:'commit %H%nAuthor: %an%nDate: %ad%n%n%s%n'
一个问题是分支名称不再显示。另一个问题是日志不再是彩色的。我怎样才能正确地做到这一点?
理想情况下,我只想 覆盖 --pretty=medium
这样它就不会显示完整的提交消息,而只显示提交的标题(或覆盖 --pretty=short
以显示日期)。这是唯一可能的吗(覆盖 built-in 漂亮的格式)?如果是,怎么做?
--decorate
不适用于自己的格式。如果你想要它,你需要使用%d
或%D
。如果你愿意,你也可以添加一些颜色来获得类似的输出,比如你可能想要这样的东西:
git log --graph --all --pretty=format:'%C(auto,yellow)commit %H%C(auto,green bold)%d%Creset%nAuthor: %an%nDate: %ad%n%n%s%n'