Fixed : git error: inflate: data stream error (invalid distance code)

Recently somehow our git got corrupted and we couldn’t push our code to server and got an error as, “error: inflate: data stream error (invalid distance code)” and “error: corrupt loose object”

$ git push origin master
Enumerating objects: 227, done.
Counting objects: 100% (227/227), done.
Delta compression using up to 8 threads
error: inflate: data stream error (invalid distance code)
error: corrupt loose object '2dd8a2ae7294a69cb1f5f786200f4c5c9b624956'
fatal: loose object 2dd8a2ae7294a69cb1f5f786200f4c5c9b624956 (stored in .git/objects/2d/d8a2ae7294a69cb1f5f786200f4c5c9b624956) is corrupt
fatal: the remote end hung up unexpectedly

When we tried below commands like “git gc –prune” or “git gc –aggressive –prune=now” or “git fsck” the error was shown as same below,

$ git gc --aggressive --prune=now
Enumerating objects: 1685, done.
Counting objects: 100% (1685/1685), done.
Delta compression using up to 8 threads
error: inflate: data stream error (invalid distance code)
error: corrupt loose object '2dd8a2ae7294a69cb1f5f786200f4c5c9b624956'
fatal: loose object 2dd8a2ae7294a69cb1f5f786200f4c5c9b624956 (stored in .git/objects/2d/d8a2ae7294a69cb1f5f786200f4c5c9b624956) is corrupt
fatal: failed to run repack

Solution :

So we went on to delete those corrupt git objects as,

$ rm -rf .git/objects/2d/d8a2ae7294a69cb1f5f786200f4c5c9b624956

and then “git push origin master” worked fine.

1 thought on “Fixed : git error: inflate: data stream error (invalid distance code)”

Leave a Comment