除了--date=(relative|local|default|iso|iso-strict|rfc|short|raw)
,正如其他人提到的那样,您还可以将自定义日志日期格式与
--date=format:'%Y-%m-%d %H:%M:%S'
这输出类似 2016-01-13 11:32:13
。
注意:如果您查看下面链接的提交,我相信您至少需要Git v2.6.0-rc0需要它才能起作用。
在完整的命令中,它将类似于:
git config --global alias.lg "log --graph --decorate
-30 --all --date-order --date=format:'%Y-%m-%d %H:%M:%S'
--pretty=format:'%C(cyan)%h%Creset %C(black bold)%ad%Creset%C(auto)%d %s'"
我在任何地方的文档中都找不到(如果有人知道在哪里找到它,请发表评论),所以我最初是通过反复试验找到占位符的。
在搜索有关此文档的文档时,我发现对Git本身的承诺表明该格式直接送入strftime
。查找strftime
(在这里或这里)占位符与列出的占位符匹配。
占位符包括:
%a Abbreviated weekday name
%A Full weekday name
%b Abbreviated month name
%B Full month name
%c Date and time representation appropriate for locale
%d Day of month as decimal number (01 – 31)
%H Hour in 24-hour format (00 – 23)
%I Hour in 12-hour format (01 – 12)
%j Day of year as decimal number (001 – 366)
%m Month as decimal number (01 – 12)
%M Minute as decimal number (00 – 59)
%p Current locale's A.M./P.M. indicator for 12-hour clock
%S Second as decimal number (00 – 59)
%U Week of year as decimal number, with Sunday as first day of week (00 – 53)
%w Weekday as decimal number (0 – 6; Sunday is 0)
%W Week of year as decimal number, with Monday as first day of week (00 – 53)
%x Date representation for current locale
%X Time representation for current locale
%y Year without century, as decimal number (00 – 99)
%Y Year with century, as decimal number
%z, %Z Either the time-zone name or time zone abbreviation, depending on registry settings
%% Percent sign
在完整的命令中,它将类似于
git config --global alias.lg "log --graph --decorate -30 --all --date-order --date=format:'%Y-%m-%d %H:%M:%S' --pretty=format:'%C(cyan)%h%Creset %C(black bold)%ad%Creset%C(auto)%d %s'"