我继承了一个带有空 sha1 的 git 存储库,用于树中的提交条目,阻止 FishEye 索引存储库。
$ git fsck
Checking object directoriies: 100%(256/256), done.
warning in tree db22a67df70dc4ff90ec4cd666da91e9c2cb0d9:
contains entries pointing to null sha1
Checking objects: 100% (416532/416532), done.
Checking connectivity: 416532, done.
寻找给定的树给我以下结果:
$ git ls-tree db22a6
100644 blob e615f18b55a39f2719112ce209c2505dd92d8e75 .gitignore
100644 blob ac852f06c5a04420356c1d5efca44d9a864e78b0 .project
160000 commit 0000000000000000000000000000000000000000 SomeDirectory
100644 blob 631c17e28026261a2ccf6bc570842cf4af9f181c GoDeploy.bat
100644 blob 40e992ab5c3868af2910135c3ac4610c3646e7f8 pom.xml
查看历史记录,我发现它SomeDirectory
最初是一个 git 子模块,并且似乎导致问题的提交是同时删除了.gitmodules
和SomeDirectory
. 现在,有一个真正的目录被称为SomeDirectory
与罪魁祸首完全相同的地方。
尽管我仍然可以尝试修复运行 agit filter-branch
以查看最终结果,但它不起作用:
$ git filter-branch --force --index-filter \
$ 'git rm --cached --ignore-unmatch SomeDirectory' \
$ --prune-empty --tag-name-filter cat -- --all
[... striped out for clarity]
Rewrite c571a3ec94e9f84471577bac41ac7375c729ef08 (76/18522)error:
cache enttry has null sha1: SomeDirectory
fatal: unable to write new index file
Could not initialize the index
[... striped out for clarity]
我接下来应该尝试什么,知道在导致问题的提交之前没有我知道的备份。