在运行查找和替换命令时,我的git仓库已经损坏(请参见:Git reset failing after find and replace)。所以我删除了一些关于哪些git告诉我不可达的打包文件。然后我运行了rm ./.git/index、git reset 命令。当运行git commit命令时,我收到了这个消息:
fatal: corrupt tree sha $someSHA
最终运行git fsck后,我的工作目录变得干净了,我可以提交了。现在的问题是当我运行git checkout some_other_branch时,出现了以下信息:
fatal: unable to read tree $someSHA
(出现的 $someSHA 是相同的)。有人能帮我吗?
编辑 1:
当我运行 git fsck --full 时,我会得到一系列的
error: refs/remotes/repo0/master does not point to a valid object!
error: refs/remotes/repo1/new-version does not point to a valid object!
...
接下来是一系列的
broken link from tree d935b909f76ea92728d71038d0a67384353e65e1
to blob 05b97658ebd47fee25b76d80ac76cbd07d77961d
...
接着出现一些丢失的blob...
编辑 2 :
运行以下命令:git log --raw --all --full-history -- subdir/my-file,我得到了:
error: refs/remotes/repo0/master does not point to a valid object!
error: refs/remotes/repo1/new-version does not point to a valid object!
...
error: Could not read 9096eb9d9dcbdf15a04e0a7c78a3744936f82ac7
fatal: cannot simplify commit 8dfd8e3d5b698dc979300d93d8e89a757abf6ec6 (because of 9096eb9d9dcbdf15a04e0a7c78a3744936f82ac7)
编辑三:
我运行了git fsck --full
,然后我得到了许多这样的行:
error: packfile .git/objects/pack/pack-fbfd8042e1e96bf5ffff88f9b5a230b8f5e4d4c4.pack does not match index
fatal: packfile .git/objects/pack/pack-fbfd8042e1e96bf5ffff88f9b5a230b8f5e4d4c4.pack cannot be accessed
...
当我运行git checkout
切换到另一个分支时,我会得到许多类似以下的消息:
error: packfile .git/objects/pack/pack-3e7a0c040a5e3d1c21b91256d583424d82a59706.pack does not match index
warning: packfile .git/objects/pack/pack-3e7a0c040a5e3d1c21b91256d583424d82a59706.pack cannot be accessed
....
fatal: unable to read tree 2ad71d368b65eff0b6fec1ef72c6fdde6e80edad
编辑4:
按照建议的答案,我解压了文件并检出时,出现了以下行:
error: packfile .git/objects/pack/pack-fbfd8042e1e96bf5ffff88f9b5a230b8f5e4d4c4.pack does not match index
warning: packfile .git/objects/pack/pack-fbfd8042e1e96bf5ffff88f9b5a230b8f5e4d4c4.pack cannot be accesse....
然后是一系列以以下内容开头的行:
error: Your local changes to the following files would be overwritten by checkout:
.idea_local_work/.name
.idea_local_work/libraries/sass_stdlib.xml
.idea_local_work/scopes/scope_settings.xml
... and then aborting