Git:“损坏的松散对象" [英] Git: "Corrupt loose object"

查看:58
本文介绍了Git:“损坏的松散对象"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每当我从遥控器拉出时,我都会收到以下有关压缩的错误.当我运行手动压缩时,我得到相同的结果:

Whenever I pull from my remote, I get the following error about compression. When I run the manual compression, I get the same:

$ git gc
error: Could not read 3813783126d41a3200b35b6681357c213352ab31
fatal: bad tree object 3813783126d41a3200b35b6681357c213352ab31
error: failed to run repack

有人知道该怎么办吗?

从猫文件我得到这个:

$ git cat-file -t 3813783126d41a3200b35b6681357c213352ab31
error: unable to find 3813783126d41a3200b35b6681357c213352ab31
fatal: git cat-file 3813783126d41a3200b35b6681357c213352ab31: bad file

从 git fsck 我得到这个(不知道它是否真的相关):

And from git fsck I get this ( don't know if it's actually related):

$ git fsck
error: inflate: data stream error (invalid distance too far back)
error: corrupt loose object '45ba4ceb93bc812ef20a6630bb27e9e0b33a012a'
fatal: loose object 45ba4ceb93bc812ef20a6630bb27e9e0b33a012a (stored in .git/objects/45/ba4ceb93bc812ef20a6630bb27e9e0b33a012a) is corrupted

谁能帮我破译这个?

推荐答案

我遇到了同样的问题(不知道为什么).

I had the same problem (don't know why).

此修复需要访问未损坏的存储库远程副本,并将保持本地工作副本完整无缺.

但它有一些缺点:

  • 您将丢失任何未推送的提交记录,并且必须重新提交.
  • 您将丢失所有藏品.

从存储库上方的父目录执行这些命令(将foo"替换为项目文件夹的名称):

Execute these commands from the parent directory above your repo (replace 'foo' with the name of your project folder):

  1. 创建损坏目录的备份:
    cp -R foo foo-backup
  2. 将远程存储库的新克隆复制到新目录:
    git clone git@www.mydomain.de:foo foo-newclone
  3. 删除损坏的 .git 子目录:
    rm -rf foo/.git
  4. 将新克隆的 .git 子目录移动到 foo:
    mv foo-newclone/.git foo
  5. 删除其余的临时新克隆:
    rm -rf foo-newclone

在 Windows 上,您需要使用:

On Windows you will need to use:

  • copy 而不是 cp -R
  • rmdir/S 而不是 rm -rf
  • move 而不是 mv
  • copy instead of cp -R
  • rmdir /S instead of rm -rf
  • move instead of mv

现在 foo 恢复了它原来的 .git 子目录,但所有本地更改仍然存在.git statuscommitpullpush 等再次正常工作.

Now foo has its original .git subdirectory back, but all the local changes are still there. git status, commit, pull, push, etc. work again as they should.

这篇关于Git:“损坏的松散对象"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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