1

1) 问题描述

我有几个包文件说unknown object type 0 at offset,与网络上 99% 的帖子不同,这不是本地问题,而是出现在远程和克隆的 repos 中。

2)我想做什么

我如何简单地删除那些无效的引用,这样我就不会被阻止在 repo 上执行其他操作?最终,我想运行一个git filter-branch --subdirectory命令将我的 9.2G 存储库拆分为子模块,但它会阻塞这些无效的包文件(注意:index-filter 有效)。

3) 完整的错误信息

$ git filter-branch --subdirectory-filter mydir HEAD

error: unknown object type 0 at offset 78171701 in /media/me/unmirrored/trash/git_filter_subdir_attempt.2020-06-21/me.git.cloned/.git/objects/pack/pack-35b37571b163f30d71a98002a7f6a30aaeeadbad.pack
fatal: packed object a30f803926d5e369b0bda4982dba89fa7127cabe (stored in /media/me/unmirrored/trash/git_filter_subdir_attempt.2020-06-21/me.git.cloned/.git/objects/pack/pack-35b37571b163f30d71a98002a7f6a30aaeeadbad.pack) is corrupt
Could not get the commits

我也把git fsck --full输出放在这里:https ://pastebin.com/WCnArrCh

4)我试过的

再取

大多数解决方案都假定您有一个未损坏的远程副本。但我所有的副本都已损坏。

删除参考

(我会在复制后添加不成功的结果响应)

git update-ref -d abc123

https://git.wiki.kernel.org/index.php/GitFaq#salvage

git 修复

(我会在复制后添加不成功的结果响应)

git-repair
git-repair --force

http://manpages.ubuntu.com/manpages/bionic/man1/git-repair.1.html

4

1 回答 1

2

哦..很多尝试..我们可以试试这个:

第一次尝试:

重新创建索引:

git co -f HEAD   # git checkout
rm .git/index
git reset

检查和修复 Git 文件系统

git fsck --full --no-dangling 

如果第一次不成功,继续。

第二次尝试:

这是非常激烈的,并且您丢失了日志历史记录。只会将最后一个版本保存到主分支中。

  1. 找到最新版本的功能;(例如:commit0 1e89694)
  2. 创建一个新的分支进行恢复; git branch commit0 1e89694;
  3. 推它; git push --all
  4. 为恢复创建工作目录; cd /tmp; git clone --depth 1 git@git.tool.com:youproject/project.git -b commit0
  5. 从这里关键检查点。
  6. 进入有问题的工作目录。
  7. 删除目录 .git
  8. 将所有内容复制到工作目录恢复中;rsync -vaRCHz . /tmp/project
  9. git add .; git ci -m "Recover $(date)"; git push --all; git merge --ff master # ci: 提交
  10. 结束!

观察:

如果您在 git 存储库中有非常多的二进制文件,则可能需要其他配置。https://stackoverflow.com/a/541490/5132101、https://opensource.com/life/16/8/how-manage-binary-blobs-git-part-7Git大文件存储 (LFS)[ https://git-lfs.github.com/]

有关别名 git 的详细信息进入帖子http://brito.blog.incolume.com.br/2013/03/guia-rapido-de-comandos-git-lado-usuario.html

于 2020-06-30T13:28:28.887 回答