Git fatal: pack has bad object at offset X: inflate returned -5
Asked Answered
S

2

15

Git has given me a lovely christmas gift... I'm trying to git push a bunch of commits, like 6 GB. And I'm getting the following error message:

-Counting objects: 525, done.
Delta compression using up to 24 threads.
Compressing objects: 100% (474/474), done.
fatal: pack has bad object at offset 3453162391: inflate returned -5
error: pack-objects died of signal 13
error: failed to push some refs to ....git

What does this mean and how is it fixed? From Google I can tell it has something to do with the size of what I'm trying to push.

This happened while it was writing.

Sirdar answered 26/12, 2014 at 5:23 Comment(3)
Have you tried pushing with --no-thin option?Marlowe
Yes, unfortunately that did not help.Sirdar
Could you try and push just a few commits (like HEAD~3) and see if that helps?Lilywhite
H
8

Based on your offset, it looks like you're trying to push some really big object (offset 3453162391 =~ >= 3GB), so zlib failed on inflating/compressing the object since there was not enough room in the output buffer (error: Z_BUF_ERROR).

This could be related to temporary lack of memory, or some buffer limits. Basically it's trying to process as much input as possible using the available output, otherwise it returns Z_BUF_ERROR. See: zlib inflate returning a buffer error.

You should re-try to see if the problem can be reproduced.

If the issue is repeatable, then try to:

  • avoid pushing large files into git repository, Git was designed to track the source code files, not very large files (like 6GB),

  • increase git message size on your client http.postBuffer, e.g.

    git config http.postBuffer 134217728 # =~ 128MB
    
  • use some alternative client which can ignore larger blobs, such as bfg, e.g.

    java -jar bfg.jar --strip-blobs-bigger-than 100M some-big-repo.git
    
  • remove the object which is causing the issue (git gc?).

Other potential issues could include:

For further readings, check this post: “pack has bad object” when pushing to remote.


If you'd like to work with large files with Git, check the followings:

Hydrostatics answered 20/4, 2016 at 12:23 Comment(1)
Running just a git gc got it for me, thanks for the answer!Echevarria
O
0

1.Clone a Shallow Copy Cloning a shallow copy of the repository may circumvent the corrupted objects. Utilize the --depth parameter to clone only the most recent commits.

git clone --depth 1 <repository-url>

2.After successfully cloning a shallow copy, you can then fetch the rest of the repository history if needed:

cd <repository-directory>
git fetch --unshallow
Optime answered 24/7 at 13:18 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.