GIT pull error - remote object is corrupted

大兔子大兔子 提交于 2019-11-26 15:44:46

问题


$ 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.


回答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"



回答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"




回答3:


It appears the answer is in the comments: git fsck




回答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.)




回答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 



回答6:


This fix the problem for me and hope helps sombody else. :) https://confluence.atlassian.com/display/FISHKB/Git+indexing+fails+due+to+bad+pack+header




回答7:


For me this was because my remote server hosting the git repo had a damaged object/file. When I tried re-packing it was running out of memory. I upgraded my instance memory and then ssh-ed back in and ran

git gc

Here is the link to the documentation:

https://git-scm.com/book/uz/v2/Git-Internals-Packfiles



来源:https://stackoverflow.com/questions/4170317/git-pull-error-remote-object-is-corrupted

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!