How can I configure git log
to show commit date
instead of author date
?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
There are several options. Probably the easiest is to just use one of the pre-baked --pretty
formats, like git log --pretty=fuller
- this will show both dates. If you want to see only one date, but make it the commit date, you can use git log --format=<some stuff>
. All the allowable codes for defining the format are documented in git help log
. The commit date is one of %cd
, %cD
, %cr
, %ct
or %ci
, depending on what format you prefer it in.
If it's something you want to do often, put it in an alias or write an auxiliary script to save on typing.
回答2:
You can use --pretty=format
and use %cr
for commit date relative.
I have the following alias in my .gitconfig
[alias]
lol = log --graph --pretty=format:"%C(yellow)%h%Creset%C(cyan)%C(bold)%d%Creset %C(cyan)(%cr)%Creset %C(green)%ce%Creset %s"
Then simply run git lol
and you'll see a nice color history with hash/date/author/comments.