GIT 拉取错误 - 远程对象已损坏
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4170317/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
GIT pull error - remote object is corrupted
提问by Senthil A Kumar
$ 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.
任何想法为什么会失败?
当我运行时,git --bare fsck-objects --full
我只看到悬空的链接,但没有断开的链接。也git gc
没有任何帮助。当我重新克隆或从另一个克隆中提取时,我没有看到此错误。
回答by cazcade_neil
As Julian said see https://confluence.atlassian.com/display/FISHKB/Git+indexing+fails+due+to+bad+pack+header
正如朱利安所说,请参阅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"
回答by logan
Adding git config --global pack.window "0"
worked for me...along with following
添加git config --global pack.window "0"
对我有用......以及以下内容
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
git clone 在克隆仓库的同时压缩数据
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 clone 存储库而不使用以下命令打包服务器上的对象来解决此问题。
git config --global pack.window "0"
git config --global pack.window "0"
回答by robrich
It appears the answer is in the comments: git fsck
答案似乎在评论中: git fsck
回答by Shiva
Just got this error, and spent half a day doing all the things described in the post : fsck, repack, gc, configuring memory options.
刚刚得到这个错误,花了半天时间把帖子里描述的东西都做了:fsck、repack、gc、配置内存选项。
Also followed this post : http://git.kernel.org/cgit/git/git.git/tree/Documentation/howto/recover-corrupted-blob-object.txt?id=HEAD
也跟着这篇文章: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.)
但最后,它就像在裸存储库中找到损坏的对象(在这种情况下为 21f3981dd35fccd28febabd96f27241eea856c50)并将其替换为未损坏的版本(可以在任何拉取的本地存储库的 .git 文件夹中找到)一样简单/从裸存储库克隆。)
回答by litian.zhuang
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:
或者在 git 服务器中,试试这个:修改:/home/git/repositories/***.git/config
,在下面添加:
[pack]
window = 0
回答by Julian
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
这为我解决了问题,并希望对其他人有所帮助。:) https://confluence.atlassian.com/display/FISHKB/Git+indexing+fails+due+to+bad+pack+header
回答by zeros-and-ones
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 repo 的远程服务器有一个损坏的对象/文件。当我尝试重新打包时,它的内存不足。我升级了我的实例内存,然后通过 ssh 重新登录并运行
git gc
Here is the link to the documentation:
这是文档的链接: