How to configure 'git log' to show 'co

2019-01-30 05:43发布

问题:

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.



标签: git git-log