GIT: fatal: Out of memory, malloc failed (tried to allocate 889192448 bytes)

前端 未结 9 1521
有刺的猬
有刺的猬 2021-01-01 17:10

I have this error while pushing my project to tfs GIT.

fatal: Out of memory, malloc failed (tried to allocate 889192448 bytes)

9条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-01 18:04

    In my experience this can happen for a few reasons:

    1. Most commonly, there are one or more files that are too large for Git to handle. In my experience this is usually a .sql, .zip, .gz or media file. Simply removing them from the repository, however, won't resolve the issue because it's in the actual Git history (inside the .git folder both on your local machine and / or on your remote server that you're pulling from). I have yet to discover a way to completely remove it from all Git history, so I usually create a new repo, create a .gitignore file in that new repo and then copy my files over there. Not a good solution but it was my best solution until I can identify a way to completely remove it from all history.
    2. It can also occur when the servers RAM / memory is low. (If you don't know how to increase your RAM then you probably shouldn't be using Git and should hire a professional developer to assist you.)

    I'm not saying these are the only possibilities. But in my experience with at least a few hundred repositories it was one of these two things every time. Usually #1.

    To see which files are the largest in your repository execute this command: ls -lS

提交回复
热议问题