Git 提交日期
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3814926/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Git commit date
提问by Samer Buna
Other than parsing git log for the date string, is there a Git native way to report the date of a certain commit?
除了解析日期字符串的 git log 之外,是否有 Git 本机方式来报告某个提交的日期?
回答by Tim Henigan
The showcommand may be what you want. Try
该 节目的命令可能是你想要的东西。尝试
git show -s --format=%ci <commit>
Other formats for the date string are available as well. Check the manual pagefor details.
日期字符串的其他格式也可用。查看手册页了解详细信息。
回答by Marcus Philip
If you want to see only the date of a tagyou'd do:
如果您只想查看标签的日期,请执行以下操作:
git show -s --format=%ci <mytagname>^{commit}
which gives: 2013-11-06 13:22:37 +0100
这使: 2013-11-06 13:22:37 +0100
Or do:
或者做:
git show -s --format=%ct <mytagname>^{commit}
which gives UNIX timestamp: 1383740557
这给出了 UNIX 时间戳: 1383740557
回答by schoetbi
If you like to have the timestamp without the timezone but local timezone do
如果您喜欢没有时区但本地时区的时间戳
git log -1 --format=%cd --date=local
Which gives this depending on your location
这取决于您的位置
Mon Sep 28 12:07:37 2015
回答by Andrey Tikhonov
if you got troubles with windows cmd command and .bat just escape percents like that
如果您在使用 windows cmd 命令和 .bat 时遇到问题,请像这样转义百分比
git show -s --format=%%ct
The % character has a special meaning for command line parameters and FOR parameters. To treat a percent as a regular character, double it: %%
% 字符对于命令行参数和 FOR 参数具有特殊含义。要将百分比视为常规字符,请将其加倍:%%