git-clone 内存分配错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1590198/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 03:53:56  来源:igfitidea点击:

git-clone memory allocation error

git

提问by nevan

I'm trying to run git clone and am receiving the following error:

我正在尝试运行 git clone 并收到以下错误:

fatal: Out of memory, malloc failed
fatal: index-pack died with error code 128
fetch-pack from 'user@server:git' failed.

I was able to successfully do a clone on my local machine, but it's failing when I try to clone to another server.

我能够在我的本地机器上成功地进行克隆,但是当我尝试克隆到另一台服务器时它失败了。

Still somewhat new to this whole git thing, so any help would be greatly appreciated. :)

对这整个 git 事情仍然有些陌生,因此将不胜感激任何帮助。:)

采纳答案by Damien MATHIEU

Do you have big files in your repository (like log files for example) ?
Apparently, your repository is too big to be retrieved on your hard drive.

您的存储库中是否有大文件(例如日志文件)?
显然,您的存储库太大而无法在硬盘上检索。

There are two things you can do :

您可以做两件事:

  • Check for big files and remove them if they're not useful (not only by committing. But also by modifying your history. If you still have your big files in our repository, it won't be smaller.
  • Do a "git gc". It'll automatically cleanup unused files and compress the repository.
  • 检查大文件并在它们无用时将其删除(不仅通过提交。还通过修改历史记录。如果您的大文件仍然在我们的存储库中,它不会更小。
  • 做一个“ git gc”。它会自动清理未使用的文件并压缩存储库。

回答by Bombe

If giton the remote machine fails due to memory constraints you might also try rsyncor scpto copy the repository to your local machine and continue with cloning from there.

如果git在远程机器上由于内存限制而失败,您也可以尝试rsyncscp将存储库复制到本地机器并从那里继续克隆。

回答by Petr Viktorin

You could run the git clonecommand with --depth -1. This will only fetch the last commit, so operations that involve history (git log, blame, or even push/pull) may not work. But, it needs less memory usage, disk space, and network transfers.

您可以git clone使用--depth -1. 这只会获取最后一次提交,因此涉及历史记录(git log、blame 甚至推/拉)的操作可能无法工作。但是,它需要更少的内存使用、磁盘空间和网络传输。

The limitations are described there: Why can't I push from a shallow clone?

那里描述了限制:为什么我不能从浅克隆中推送?

回答by olibre

Maybe your local machine in 32 bits and the other server is 64 bits... I got a similar issue on Windows using MSysGit32 bits. The git 64 bits from Cygwindid the job.

也许你的本地机器是 32 位的,而另一台服务器是 64 位的......我在使用MSysGit32 位的Windows 上遇到了类似的问题。Cygwin的 git 64 位完成了这项工作。

My original answeris available on question Git on Windows, “Out of memory - malloc failed”.

我的原始答案可在Windows上的Git问题“内存不足 - malloc 失败”中找到