3

I have the following error upong fetching, pulling or cloning my repo:

$ git fetch
remote: error: Could not read 9bc3bd2d69d3eeebdbb916f5b6126b7714f90e75
remote: fatal: bad tree object 9bc3bd2d69d3eeebdbb916f5b6126b7714f90e75
remote: aborting due to possible repository corruption on the remote side.
error: git upload-pack: git-pack-objects died with error.
fatal: git upload-pack: aborting due to possible repository corruption on the remote side.
fatal: protocol error: bad pack header

When I git -fsck

$ git fsck
Checking object directories: 100% (256/256), done.
Checking objects: 100% (148557/148557), done.

When I git prune then git gc

$ git gc
Counting objects: 148557, done.
Compressing objects: 100% (26144/26144), done.
Writing objects: 100% (148557/148557), done.
Total 148557 (delta 90234), reused 148557 (delta 90234)

I've searched for some solutions here and some suggest deleting the object tree or moving it but:

$ git ls-tree 9bc3bd2d69d3eeebdbb916f5b6126b7714f90e75
fatal: not a tree object

What should I do here? (This repo is on gitlab and I tried fetching it on sourcetree and git bash)

Jean Henry
  • 436
  • 4
  • 14

1 Answers1

3

I confirm I cannot clone that repo either ;) (I have access to Jean Henry's repo)

I described the proper recovery process 6 years ago, referenced again in 2014.

The goal is to take any still functional recent clone and unpack its pack file, to search for the missing object (here a tree).
See "How to recover Git objects damaged by hard disk failure?"

mv .git/objects/pack/* <somewhere>
for i in <somewhere>/*.pack; do
  git unpack-objects -r < $i
done
rm <somewhere>/*

Once unpacked, you can look for the file ./git/objects/9b/c3bd2d69d3eeebdbb916f5b6126b7714f90e75: copy it to the bare repo on the server.
And do a git fsck to confirm the error is gone.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250