运行find and replace命令时,我的git repo被破坏了(参见这里:Git reset failing after find and replace)。所以我删除了一些包文件,告诉我哪些git告诉我无法访问。所以我运行了rm ./.git/index,git reset。运行git commit时,我收到了这条消息:
fatal: corrupt tree sha $someSHA
最后git fsck,我的工作目录变得干净了,我能够提交。 pb现在是当我运行git checkout some_other_branch时,我收到了这条消息
fatal: unable to read tree $someSHA
(出现的$ someSHA是相同的)。有人可以帮帮我吗?
当我运行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
...
然后是一些丢失的斑点......
我运行了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
按照建议的答案,我解压缩了文件,当我检查时,我得到了 有些行如此:
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
答案 0 :(得分:20)
首先:备份您的.git
目录,以防您在此过程中损坏更多内容。然后:
对于每个损坏的packfiles,运行:
mv .git/objects/pack/pack-**yourpack**.pack oldpack
git-unpack-objects -r < oldpack
再次运行git fsck --full
和git checkout
,向我们提供输出。
现在看起来你应该可以退房了,但是你必须运行git checkout -f **yourbranch**
,因为你的工作目录中有尚未提交的更改。但是,当您运行git checkout -f
时,这些更改将会丢失。
答案 1 :(得分:0)
使用此存储库另一个.git副本中的相同文件重写此文件。