腐败的git回购问题 [英] Problems with corrupt git repo

查看:247
本文介绍了腐败的git回购问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的git repo在运行find和replace命令时被损坏(请参阅:找到并替换后Git重置失败)。所以我删除了一些关于哪个git告诉我无法访问的包文件。所以我跑rm ./.git/index,git reset。在运行git commit时,我收到了以下消息:

  fatal:corrupt tree sha $ someSHA 

最后git fsck,我的工作目录变得干净而且我能够提交。 pb现在是当我运行git checkout some_other_branch时,我收到了这条消息:

 致命:无法读取树$ someSHA 

(出现的$ someSHA是相同的)。有人可以帮助我吗?

编辑1:



当我运行git fsck --full时,

 错误:refs / remotes / repo0 / master没有指向一个有效的对象! 
错误:refs / remotes / repo1 / new-version不指向有效的对象!
...

然后是一系列

 从树中断开的链接d935b909f76ea92728d71038d0a67384353e65e1 
到blob 05b97658ebd47fee25b76d80ac76cbd07d77961d
...

,然后出现一些丢失的斑点...

编辑2:



我运行git log --raw --all --full-history - subdir / my-file,我得到

 错误:refs / remotes / repo0 / master没有指向一个有效的对象! 
错误:refs / remotes / repo1 / new-version不指向有效的对象!
...
错误:无法读取9096eb9d9dcbdf15a04e0a7c78a3744936f82ac7
致命:无法简化提交8dfd8e3d5b698dc979300d93d8e89a757abf6ec6(因为9096eb9d9dcbdf15a04e0a7c78a3744936f82ac7)



编辑3:



我运行 git fsck --full ,我收到了很多行

 错误:packfile .git / objects / pack / pack-fbfd8042e1e96bf5ffff88f9b5a230b8f5e4d4c4.pack不匹配索引
致命:packfile .git / objects / pack / pack-fbfd8042e1e96bf5ffff88f9b5a230b8f5e4d4c4.pack无法访问
...

运行 git checkout 到另一个分支时,我得到了很多消息:

  error:packfile .git / objects / pack / pack-3e7a0c040a5e3d1c21b91256d583424d82a59706.pack不匹配索引
警告:packfile .git / objects / pack / pack-3e7a0c040a5e3d1c21b91256d583424d82a59706.pack无法访问
....
致命:无法读取树2 ad71d368b65eff0b6fec1ef72c6fdde6e80edad



编辑4:



建议的答案,我解压缩文件,当我检出时,我得到了
一些行,如下所示:

  error: packfile .git / objects / pack / pack-fbfd8042e1e96bf5ffff88f9b5a230b8f5e4d4c4.pack不匹配索引
警告:packfile .git / objects / pack / pack-fbfd8042e1e96bf5ffff88f9b5a230b8f5e4d4c4.pack无法访问....

然后是一系列以

开头的行

 错误:您对本地文件的更改将被checkout覆盖:
.idea_local_work / .name
.idea_local_work / libraries / sass_stdlib.xml
.idea_local_work / scopes / scope_settings .xml
...然后放弃


解决方案

第一步:备份你的 .git 目录,以防万一你在这个过程中弄坏了更多的东西。然后:


  • 放回您可用的最佳包装文件版本。

  • 对于每个损坏的包文件,运行:

      mv .git / objects / pack / pack  -  ** yourpack **。pack旧包
    git-unpack-objects -r<旧包


  • 运行 git fsck --full git checkout ,给我们输出。

  • 看起来你现在应该可以检查出来,但是您必须运行 git checkout -f ** yourbranch ** ,因为您的工作目录中的变化尚未提交。但是,当您执行 git checkout -f 时,这些更改将会丢失。

    My git repo got corrupted while running a find and replace command (See here: Git reset failing after find and replace). So I deleted some pack files about which git told me that there were not reachable. So I ran rm ./.git/index, git reset. When running git commit, I got this message :

    fatal: corrupt tree sha $someSHA
    

    Finally git fsck, my working directory went clean and I was able to commit. The pb now is that when I run git checkout some_other_branch, I got this message

    fatal: unable to read tree $someSHA
    

    (The $someSHA appearing are the same). Someone could help me ?

    Edit 1 :

    when I run git fsck --full, I get a serie of

    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!
    ...
    

    then a serie of

    broken link from    tree d935b909f76ea92728d71038d0a67384353e65e1
                  to    blob 05b97658ebd47fee25b76d80ac76cbd07d77961d
    ...
    

    and then some missing blobs...

    Edit 2 :

    I ran git log --raw --all --full-history -- subdir/my-file, and I get

    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)
    

    Edit 3 :

    I ran git fsck --full, the I get numerous lines as so

    error: packfile .git/objects/pack/pack-fbfd8042e1e96bf5ffff88f9b5a230b8f5e4d4c4.pack does not match index
    fatal: packfile .git/objects/pack/pack-fbfd8042e1e96bf5ffff88f9b5a230b8f5e4d4c4.pack cannot be accessed
    ...
    

    when running git checkout to another branch I got numerous messages as so :

    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
    

    Edit 4 :

    following the suggested answer, I unpacked the files and when I checked out, I got some lines as so :

    error: packfile .git/objects/pack/pack-fbfd8042e1e96bf5ffff88f9b5a230b8f5e4d4c4.pack does not match index
    warning: packfile .git/objects/pack/pack-fbfd8042e1e96bf5ffff88f9b5a230b8f5e4d4c4.pack cannot be accesse....
    

    and then a serie of lines beginning with

     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
    

    解决方案

    First: Make a backup of your .git directory in case you corrupt things more in this process. Then:

    • Put back the best version of the packfiles you have available.
    • For each of the corrupt packfiles, run:

      mv .git/objects/pack/pack-**yourpack**.pack oldpack
      git-unpack-objects -r < oldpack
      

    • Run git fsck --full and git checkout again, give us the output.

    • Looks like now you should be able to check out, but you will have to run git checkout -f **yourbranch**, as you have changes in your working dir that are not yet committed. These changes will get lost when you run git checkout -f, though.

    这篇关于腐败的git回购问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆