The error fatal: error -1 inflating zlib stream or error: inflate: data stream error (invalid distance code) indicates that one of Git’s compressed packfile objects (.git/objects/pack/) suffered disk corruption or an incomplete download during a git pull or git fetch.

Step 1: Identify Corrupted Packfiles (git fsck)

Git Repository Integrity Auditbash
# Run Git file system check to detect corrupted objects
git fsck --full
 
# Sample Output:
# error: inflate: data stream error (invalid distance code)
# error: failed to unpack compressed object 4b825dc642cb6eb9a060e54bf8d69288fbee4904

Step 2: Remove Corrupted Packfile & Re-fetch from Remote

Terminal Repair Commandsbash
# Move loose corrupted packfiles to a backup folder outside .git
mkdir -p /tmp/git_corrupt_backup
mv .git/objects/pack/*.pack /tmp/git_corrupt_backup/
mv .git/objects/pack/*.idx /tmp/git_corrupt_backup/
 
# Re-fetch fresh objects and packfiles directly from remote origin
git fetch --all --prune --unshallow
 
# Re-link local branch to origin main
git reset --hard origin/main