How to configure 'git log' to show 'co

2019-01-30 05:35发布

How can I configure git log to show commit date instead of author date?

标签: git git-log
2条回答
我想做一个坏孩纸
2楼-- · 2019-01-30 06:16

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.

查看更多
迷人小祖宗
3楼-- · 2019-01-30 06:23

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.

查看更多
登录 后发表回答