从某个日期开始,git log没有列出提交记录

3
我刚使用git fast-import将大量源代码历史从MKS迁移到了一个Git仓库。问题在于,当我使用“git log”命令查看最近10天该仓库中的所有提交时,有些提交没有被列出,但是它们应该被列出。以下是我用来重现这个问题的步骤:
当我输入下面这个命令以按作者“renato”列出3个提交时:
git log --pretty=format:"%h %an %ad" --author renato -3

我得到了以下输出:
8cd40f6 renatoo Mon Feb 15 10:35:28 2016 -0600
a2694d2 renatoo Fri Feb 5 13:30:14 2016 -0600
57ee8d3 renatoo Thu Jan 14 15:08:33 2016 -0600

请注意第一个日期是2016年2月15日,也就是5天前。

但如果我输入以下命令以列出他在过去10天内的所有提交,则不显示任何内容:

git log --pretty=format:"%h %an %ad" --author renato --since=10.days

实际上我已经尝试过这个功能,我发现可以为"--since"设定一个24年的值来显示他的提交记录:

>git log --pretty=format:"%h %an %ad" --author renato --since=24.years
8cd40f6 renatoo Mon Feb 15 10:35:28 2016 -0600
a2694d2 renatoo Fri Feb 5 13:30:14 2016 -0600
57ee8d3 renatoo Thu Jan 14 15:08:33 2016 -0600
aa0d926 renatoo Thu Jan 14 15:08:08 2016 -0600
13fdca1 renatoo Thu Jan 14 15:08:22 2016 -0600
32c5af7 renatoo Wed Jan 20 08:59:56 2016 -0600
68231db renatoo Thu Jan 14 15:18:55 2016 -0600
2c25c72 renatoo Thu Jan 14 15:17:28 2016 -0600
1d7ddd3 renatoo Thu Jan 14 15:18:08 2016 -0600
9677ed9 renatoo Thu Jan 14 15:16:51 2016 -0600
1da4267 renatoo Thu Jan 14 15:14:39 2016 -0600
c64b3e1 renatoo Thu Jan 14 15:14:03 2016 -0600
ea9fe12 renatoo Thu Jan 14 15:10:10 2016 -0600
708b712 renatoo Thu Jan 14 15:12:27 2016 -0600
b24a2cf renatoo Thu Jan 14 15:13:12 2016 -0600
15c5abe renatoo Fri Jan 29 15:32:53 2016 -0600
a698bbe renatoo Mon Feb 15 10:36:51 2016 -0600
861b322 renatoo Fri Feb 5 13:29:37 2016 -0600
3da4bcf renatoo Fri Jan 29 15:32:17 2016 -0600
3a1db85 renatoo Fri Jan 29 15:32:14 2016 -0600
d60841f renatoo Mon Feb 15 10:36:17 2016 -0600
132d762 renatoo Fri Feb 5 13:28:49 2016 -0600
764d6e0 renatoo Mon Feb 15 10:36:23 2016 -0600
9d35f44 renatoo Fri Feb 5 13:29:10 2016 -0600
f808b8b renatoo Mon Feb 15 10:36:09 2016 -0600
2b04034 renatoo Fri Feb 5 13:28:37 2016 -0600
682a776 renatoo Mon Jan 25 11:46:30 2016 -0600
1276d4b renatoo Fri Jan 22 10:42:39 2016 -0600
ad77333 renatoo Mon Jan 25 11:47:09 2016 -0600
2df0aec renatoo Fri Jan 22 10:42:25 2016 -0600
>

但是23年并不起作用:
>git log --pretty=format:"%h %an %ad" --author renato --since=23.years
>

我尝试过很多不同的方法,包括查看提交者日期和作者日期(在这种情况下,它们都匹配),以及尝试选项--all、--branches和--reflogs。

有没有一种不同且更可靠的方法来获取给定时间范围内的所有提交(我个人感兴趣的是最近3天内的提交)?可能存储库存在一些损坏吗?

编辑:修复了最后一个示例命令行。


看一下 git rev-parse --since=10.days 打印了什么可能会很有趣。例如,与 --since=24.years 的打印进行比较。(两者应该都转换为一个自1970年以来的秒数的 --max-age。) - torek
git rev-parse --since=10 天
--max-age=1455169600
git rev-parse --since=24 年
--max-age=698651205
- Arturo Cuebas
嗯,那些看起来很合理。所以,为什么10天版本还是不工作,我还是没有头绪... - torek
1个回答

0

在您的情况下,答案非常简单:

git log --since=10.days 

这里有一些你可以使用的其他例子。

--after--before

# You can also pass in relative references 
# like "1 week ago" and "yesterday":    
git log --after="2014-7-1"
get log --after="yesterday"

--since 和 --until

--since--until 标志与 --after--before 是同义词。


更多示例:

git log --before <date>
git log --after <date>
git log --after 2.days.ago
git log --after <date> --before <date>

当问题的重点是他们特别尝试过那个方法,而那个方法对他们不起作用,这怎么是简单答案呢? - underscore_d

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接