`git log` 中的奇怪行为

`git log` 中的奇怪行为

--since和指定的日期范围--until似乎不起作用,

$ git log --format="%cd %h" --since="2009-11-20 10:25:59" --until="2009-12-25 00:00:00" --date=iso .
2009-12-23 00:07:24 +0000 fa2261b
2009-12-23 00:07:20 +0000 0fe0295
2009-12-22 22:47:52 +0000 33e516c
2009-12-22 22:47:48 +0000 a5ed271
2009-12-22 15:28:35 +0000 eae904e
2009-12-21 05:05:32 +0000 874436f

$ git log --format="%cd %h" --since="2009-11-20 10:26:00" --until="2009-12-25 00:00:00" --date=iso .
(Empty output)

$ git log --format="%cd %h" --since="2009-12-21" --until="2009-12-24" --date=iso .
(Empty output)

我不确定我是否输入了正确的日期文字,在 git-log(1) 中它说:

   --since=<date>, --after=<date>
       Show commits more recent than a specific date.

   --until=<date>, --before=<date>
       Show commits older than a specific date.

但它没有提到语法<date>

答案1

您包含“--date=iso”参数,因此您可能正在使用 ISO 8601 标准日期格式——您需要的有关 ISO 8601 日期格式的信息可以在这里找到:

  ISO 8601 - 日期和时间的数字表示
  http://www.iso.org/iso/support/faqs/faqs_widely_used_standards/widely_used_standards_other/date_and_time_format.htm

按照“YYYY-MM-DDThh:mm:ss”,我认为您只需要在日期和时间之间使用字母“T”而不是空格。

但是,有些人认为必须删除分隔符,因此您也可以尝试删除破折号(在日期中)和冒号(也提供时间)。

相关内容