Search code examples
gitgit-cloneinflate

Git - Finding a file with its offset


I'm trying to clone a remote Git repo.

I've done it before without any issues, but on this project, I get the error

fatal: pack has bad object at offset 289293315: inflate returned -5

fatal: index-pack failed

How can I find which file is causing the error? I tried git show :289293315

But it's apparently not an index :

fatal: Path '289293315' does not exist (neither on disk nor in the index).


Solution

  • This is an error in a pack file. A pack file contains many individual Git objects, all mushed together and delta-compressed.

    To find the bad pack file, look in the .git/objects/pack directory, which will contain one or more .pack files and corresponding .idx files. You can, for instance, run git index-pack -v on each .pack file, to look for issues. That's what is happening now (without the -v).

    You can also use git unpack-objects -r after moving the bad .pack file out of the repository itself, to attempt to recover whatever good objects remain. However, your best bet is probably to find a good clone of the repository. Meanwhile you should figure out why your existing pack file went bad: Was something corrupting files? Is your storage device failing?