error updating changes :out of memory, malloc failed 的解决方法

问题描述

在提交代码时出现报错:

error updating changes :out of memory, malloc  failed (tried to allocate XXXXXX bytes)
error: failed to push some refs to 'https://github.com/xxxxxxx/xx.git'

原因分析:

从字面意思可以看出原因是内存溢出

找到git的配置文件.gitconfig,发现postBuffer并没有设置(如果设置了可以改大一点,或者注释掉)

可能是自己本地一些 “悬空对象”太多(git删除分支或者清空stash的时候,这些其实还没有真正删除,成为悬空对象,我们可以使用merge命令可以从中恢复一些文件),

解决方案:

1.使用命令

1.输入命令:git fsck --lost-found,可以看到好多“dangling commit”
2.清空他们:git gc --prune=now,完成

2.或者使用工具:到代码存放的文件夹去clean一下

重新代码提交成功。

创作不易,关注💖、点赞👍、收藏🎉就是对作者最大的鼓励👏,欢迎在下方评论留言🧐

posted on 2022-07-12 21:59  猫的树kireCat  阅读(101)  评论(0编辑  收藏  举报