与腐败的git回购问题(Problems with corrupt git repo)

2019-07-18 21:25发布

运行查找和替换命令,而我的git仓库被损坏了(在这里看到: Git的复位失败后查找和替换 )。 所以我删除了一些包文件关于这混帐告诉我,有没有到达。 于是我就RM ./.git/index,git的复位。 当运行git的承诺,我得到这个消息:

fatal: corrupt tree sha $someSHA

最后的git fsck的,我的工作目录就干净,我才得以提交。 铅是现在,当我运行的git结帐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
...

然后一些缺失的斑点...

编辑2:

我跑git的日志--raw --all --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!
...
error: Could not read 9096eb9d9dcbdf15a04e0a7c78a3744936f82ac7
fatal: cannot simplify commit 8dfd8e3d5b698dc979300d93d8e89a757abf6ec6 (because of 9096eb9d9dcbdf15a04e0a7c78a3744936f82ac7)

编辑3:

我跑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

Answer 1:

第一:让你的备份.git目录的情况下,在这个过程中,你腐朽的东西更多。 然后:

  • 放回你有可用的打包文件的最好的版本。
  • 对于每一个腐败打包文件中,运行:

     mv .git/objects/pack/pack-**yourpack**.pack oldpack git-unpack-objects -r < oldpack 
  • 运行git fsck --fullgit checkout一次,给我们的输出。

  • 貌似现在你应该能查出来,但是你必须运行git checkout -f **yourbranch** ,因为您有尚未提交你的工作目录的变化。 当您运行这些变化会迷路git checkout -f ,虽然。



文章来源: Problems with corrupt git repo