git push 内存不足,malloc 失败 [英] git push Out of memory, malloc failed

查看:67
本文介绍了git push 内存不足,malloc 失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将我的更改远程推送到 GitHub,但经常 git 由于

I am trying to push my changes remotely to GitHub, every so often git fails due to

C:devprojects>git push -v
Pushing to https://user@github.com/mycompany/My-Project.git
Password for 'github.com':
fatal: Out of memory, malloc failed (tried to allocate 524288000 bytes)
fatal: write error: Invalid argument

这非常非常令人恼火.我已经运行了以下命令,升级了 git(它清除了我的设置并造成了很多痛苦,但我离题了)

This is very, very aggravating. I have run the following commands, upgraded git (which wiped out my settings and caused lots of pain, but I digress)

git gc --auto --prune=today --aggressive
git repack

我什至提高了

http.postbuffer

但最终它会再次失败.

这是一个典型的 Rails 3.1 应用程序,磁盘上的项目总大小为 9.69 MB.

This is a typical Rails 3.1 application, total project size on disk is 9.69 MB.

推荐答案

我的建议是尝试几个与pack相关的git参数:

My advice is to try several git parameters related with pack:

[pack]
   threads = 1
   deltaCacheSize = 128m
   windowMemory = 50m

对我来说更好的结果是设置 git config pack.threads 1git config pack.windowMemory 50m(默认为 10m).

What it got better results for me was setting git config pack.threads 1 and git config pack.windowMemory 50m (default is 10m).

仍然,我的主机没有足够的 RAM 内存 (2GB) 并且一直失败.我硬复制了 repo 并将其移动到另一台具有更多 RAM (8GB) 的机器上.它变得更好了,但仍然失败了.

Still, my host didn't have enough RAM memory (2GB) and kept failing. I hard copied the repo and moved it to another machine with more RAM (8GB). It got better but still failed.

最后,我下载了最新版本的 git (https://github.com/git/git),编译并安装.只需使用相同的参数运行 git repack -adf 即可解决问题.之后我运行 git gc --aggressive --prune=now

Finally, I downloaded the latest version of git (https://github.com/git/git), compile it and install it. That fixed the problem just by running git repack -adf with the same parameters. After that I run git gc --aggressive --prune=now

在我的本地机器上修复 repo 后,我将它推送到 master,覆盖远程 repo,git push -f origin master.

Once I got the repo fixed in my local machine I pushed it to master, overwriting the remote repo, git push -f origin master.

为了防止将来出现类似错误,尽量不要向 repo 添加不必要的大文件(在我的情况下,我得到了 3.5GB 的 SQL 转储 :))并禁用大文件(例如图像、PDF、视频)的增量压缩).将以下行添加到 .gitattributes:

To prevent similar errors in the future try not to add unnecessary large files to the repo (in my case I got a SQL dump of 3.5GB :)) and disable delta compression for large files (such as images, PDFs, videos). Add the following lines to .gitattributes:

*.pdf -delta
*.jpg -delta

这篇关于git push 内存不足,malloc 失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆