我有一个git回购,这是从RCS转换通过CVS很多年前。当我试图将它推到GitHub时,由于最初的两次提交日期不对,它被拒绝了:
$ git fsck
Checking object directories: 100% (256/256), done.
error in commit 38f10a1a015625149ea06f2f633e9ba446912b27: badDateOverflow: invalid author/committer line - date causes integer overflow
error in commit 0436a5befd4fee58693c2293e72be53b84705539: badDateOverflow: invalid author/committer line - date causes integer overflow当我查看这些提交时,很明显日期是坏的(它们是负的):
$ git cat-file -p
tree 75e9d9b58efcc2b706e38967cff75935e656fdf1
parent 0436a5befd4fee58693c2293e72be53b84705539
author John Tang Boyland <boyland@uwm.edu> -59025288066 +0000
committer John Tang Boyland <boyland@uwm.edu> -59025288066 +0000
Updated for CS654 Spring 1999.这似乎是git-过滤器-回购应该能够处理的事情。我看到了修复电子邮件、姓名和提交信息的标志,但日期却没有。我尝试了一次运行,在那里我只是修剪无法到达的提交,它留下了糟糕的日期到位。然后我尝试使用git fast-export并用正确的unix时间戳编辑负数。当我在一个空存储库中使用git fast-import时,我得到了大量的统计数据,但是空存储库仍然是空的,这可能是因为提交结构被破坏了。我猜想解决这个问题的唯一方法是使用git-filter-repo的提交回调,但我不知道如何修正日期。
我试过了
$ git-filter-repo --commit-callback '
if (commit.committer_date == -59025288066) :
commit.committer_date = 932873934
'它运行得很好,但对糟糕的约会没有影响。我试着做同样的事情,但是重复引用日期(万一它们被读成字符串),同样没有效果。
我在同一主题上看到了一个现有的问题,但答案并没有说明如何使用git-filter-repo来修复日期:How can I fix "bad date" issues in a git repository?
发布于 2022-01-08 19:36:23
好的,经过一些实验,我发现了如何使用钩子。这是不够的双重引用日期戳,它必须有+0000部分也。即使这样也是不够的。我不得不引用"b“字串。解决方案是使用钩子运行git-filter-repo,如
git-filter-repo --commit-callback '
if (commit.committer_date == b"-59025288066 +0000") :
commit.committer_date = b"932873934 +0000"
'当然,我必须对author_date做同样的事情,对于另一个提交也是如此。
https://stackoverflow.com/questions/70635488
复制相似问题