GIT pull error - remote object is corrupted

56,662

Solution 1

As Julian said see https://confluence.atlassian.com/display/FISHKB/Git+indexing+fails+due+to+bad+pack+header

It really can be a memory issue, and to make sure we don't lose the solution here it is:

git config --global pack.windowMemory "100m"
git config --global pack.SizeLimit "100m" 
git config --global pack.threads "1"

Solution 2

Adding git config --global pack.window "0" worked for me...along with following

git config --global pack.windowMemory "100m"
git config --global pack.packSizeLimit "100m" 
git config --global pack.threads "1"

Reason:

Git clone compresses the data while cloning the repository

It compresses the data on the server memory before receiving the data/files.

If the server has out of memory you will get the above error while packing the objects

You can fix the issue by making git clone the repository without packing the objects on the server with the following.

git config --global pack.window "0"

Solution 3

It appears the answer is in the comments: git fsck

Solution 4

Just got this error, and spent half a day doing all the things described in the post : fsck, repack, gc, configuring memory options.

Also followed this post : http://git.kernel.org/cgit/git/git.git/tree/Documentation/howto/recover-corrupted-blob-object.txt?id=HEAD

But in the end, it was as simple as finding the damaged object(21f3981dd35fccd28febabd96f27241eea856c50 in this case) in the bare repository and replacing it with the non damaged version(which can be found in the .git folder of any of the local repositories which pulled/cloned from the bare repository.)

Solution 5

in the client,try do it like this:

git config --global pack.windowMemory "100m"
git config --global pack.SizeLimit "100m" 
git config --global pack.threads "1"
git config --global pack.window "0"

or in the git server, try this: modify: /home/git/repositories/***.git/config,add below:

[pack]
         window = 0 
Share:
56,662
Senthil A Kumar
Author by

Senthil A Kumar

SCM Engineer

Updated on July 09, 2022

Comments

  • Senthil A Kumar
    Senthil A Kumar almost 2 years
    $ git pull
    
    remote: fatal: object 21f3981dd35fccd28febabd96f27241eea856c50 is corrupted
    error: git upload-pack: git-pack-objects died with error.
    fatal: git upload-pack: aborting due to possible repository corruption on the remote side.
    remote: aborting due to possible repository corruption on the remote side.
    fatal: protocol error: bad pack header
    

    Any ideas why this is failing?
    When I run git --bare fsck-objects --full I just see dangling links but no broken links. Also git gc didn't help in any way. When I reclone or do pull from another clone, I don't see this error.

  • kleopatra
    kleopatra over 10 years
    Note that link-only answers are discouraged, SO answers should be the end-point of a search for a solution (vs. yet another stopover of references, which tend to get stale over time). Please consider adding a stand-alone synopsis here, keeping the link as a reference.
  • yig
    yig almost 9 years
    If your server uses the smart http protocol, you might not be able to set a global config for the process. Instead, cd into the directory of the git repository itself and run the same commands without --global.
  • Jon Watte
    Jon Watte almost 8 years
    It's much more likely that the server ran out of RAM creating pack files.
  • Aaron Wang
    Aaron Wang almost 8 years
    Is this config for client or server?
  • logan
    logan over 7 years
    @AaronWang : This is for client machine where you cloned your repository !!
  • blamb
    blamb about 7 years
    atlassan solution mentioned here worked for me, just ssh'd, ran the 3 commands, exited, and pulled success on first try.
  • Sqripter
    Sqripter over 6 years
    This solved the issue for me too, i.e. the configuration change on the server side