unknown object type 0 at offset - all repo mirrors corrupted preventing filter-branch subdirectory-filter

≡放荡痞女 提交于 2020-07-07 11:29:06

问题


1) Problem Description

I have several pack files saying unknown object type 0 at offset, and unlike 99% of posts on the web this isn't a local problem but appears in both remote and cloned repos.

2) What I want to do

How do I simply remove those invalid references so that I'm not blocked from doing other operations on the repo? Ultimately, I want to run a git filter-branch --subdirectory command to split my 9.2G repo into submodules, but it chokes on these invalid pack files (note: index-filter works).

3) Full error message

$ 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

I've also put the git fsck --full output here: https://pastebin.com/WCnArrCh

4) What I've tried

fetch again

Most solutions assume you have an uncorrupted remote copy. But all my copies are corrupt.

Delete the reference

(I will add the unsuccessful outcome response after reproducing)

git update-ref -d abc123

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

git-repair

(I will add the unsuccessful outcome response after reproducing)

git-repair
git-repair --force

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


回答1:


Oh.. many attempts.. We Can be try this:

First Try:

Recreate index:

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

Check and repair a Git filesystem

git fsck --full --no-dangling 

if first not sucess, continue.

Second try:

This is very drastic, and you lost log history. Will preservate only last version into main branch.

  1. Locate last version functional; (ex: commit0 1e89694)
  2. Create a new branch for recover; git branch commit0 1e89694;
  3. Push it; git push --all
  4. Create workdirectory for recover; cd /tmp; git clone --depth 1 git@git.tool.com:youproject/project.git -b commit0
  5. From here critical checkpoint.
  6. Go into workdirectory with problem.
  7. Remove directory .git
  8. copy all content into workdirectory recovery;rsync -vaRCHz . /tmp/project
  9. git add .; git ci -m "Recover $(date)"; git push --all; git merge --ff master
  10. Finish!

Obs:

If you have very binaries into git repositories, maybe necessary other configurations suply. https://stackoverflow.com/a/541490/5132101, https://opensource.com/life/16/8/how-manage-binary-blobs-git-part-7 or Git Large File Storage (LFS)[https://git-lfs.github.com/]



来源:https://stackoverflow.com/questions/62547475/unknown-object-type-0-at-offset-all-repo-mirrors-corrupted-preventing-filter-b

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!