Git提交日期


Answers:


268

节目 的命令可能是你想要的东西。尝试

git show -s --format=%ci <commit>

日期字符串的其他格式也可用。检查手册页了解详情。


19
要获取没有差异的提交,请使用log -1代替show
Josh Lee 2010年

36
或在命令中添加“ -s”:git show -s --format="%ci" <commit>
aprock

6
对于未来的用户:您可以查看作者日期%ai
user541686

4
要获取unix时间戳:使用git show -s --format =%ct <commit>
xiaoweiz 16-10-20

2
如果您想要其他日期格式,则可以使用git show -s --format=%cd --date=short <commit>(将给出例如2016-11-02)或git show -s --format=%cd --date=short <commit>git show -s --format=%cd --date=format:%Y <commit>(此示例将仅打印年份)。有关详细信息,请参见此答案
变形虫

26

如果您只想查看标签的日期,请执行以下操作:

git show -s --format=%ci <mytagname>^{commit}

这使: 2013-11-06 13:22:37 +0100

或执行:

git show -s --format=%ct <mytagname>^{commit}

它提供了UNIX时间戳: 1383740557


19

如果您希望没有时区但本地时区具有时间戳

git log -1 --format=%cd --date=local

这取决于您的位置

Mon Sep 28 12:07:37 2015

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.