I know this has been asked a lot but I did not manage to get any solution to solve my problem.

My coworker assigned me on a new project. The application is hosted on test Debian server with git installed.

First I have created my branch :

git checkout -b mybranch

Then I have done small modifications to some files.

When I tried to push it to Github (using my github account)

git add myfile.php
git commit -m "my first commit"
git push origin mybranch

I get this error :

fatal: Out of memory, malloc failed

I don't understand what this mean. The total size of the files I tried to push is 156Ko. Moreover the total size of the project is only 10,9Mo.

I tried to reboot the server but the same happen.

When I run free on the server I get :

             total       used       free     shared    buffers     cached
Mem:        505312     239532     265780          0      51576      71580
-/+ buffers/cache:     116376     388936
Swap:            0          0          0

My coworkers never had this problem before, even on the same test server.

Can someone highlight me on the reason of this error and a possible workaround?
Thanks in advance.

  • Have you tried changing the settings in .git/config as suggested here?
    – 111---
    May 13, 2015 at 14:06
  • Yes but no luck...
    – hg8
    May 13, 2015 at 14:11
  • Can you try again with the -v flag, git push -v, and post the full error (redacting your repo info of course).
    – 111---
    May 13, 2015 at 14:24
  • The -v flag does not add anything to the error message...
    – hg8
    May 13, 2015 at 14:33
  • This looks like a bug somewhere. What version of Debian does the machine have? Can you reproduce the problem by cloning a local repository rather than one on github? If you can reproduce the problem without using any credentials or private information, run strace -o git.strace -tt git push origin mybranch (or whatever the failing git … command is) and post the resulting git.strace file (don't post the trace if it might contain something like a password). May 13, 2015 at 22:20

3 Answers 3


Turn out it was indeed a ram problem. 268mo was not enough for git to function properly.

I solved the problem by adding 1Go of swap to the server:

$ sudo fallocate -l 1G /swapfile
$ sudo chmod 600 /swapfile
$ sudo mkswap /swapfile
$ sudo swapon /swapfile
  • How did you do that, Im getting same issue.
    – Pramod
    May 31, 2016 at 10:08
  • for example take a look at it: linuxize.com/post/how-to-add-swap-space-on-ubuntu-18-04 Nov 15, 2019 at 20:32
  • 1
    This turned out to be my issue as well. Running on a small AWS EC2
    – ParoX
    May 27, 2020 at 4:33
  • Great answer, I let myself top it up with increasing internal GIT limits following creation of the swap file: git config pack.packSizeLimit 1g git config pack.deltaCacheSize 1g git config pack.windowMemory 1g git config core.packedGitLimit 1g git config core.packedGitWindowSize 1g
    – azgooon
    Feb 14 at 10:57

I was getting same error as I was running jenkins in docker

I stop container and run git and this fixed the problem

Try to free some more space in RAM


I checked my RAM usage.

Enter command:

free -mh

I got very little left of RAM.

So I stopped my docker container and checked my RAM again.

Now it's back to normal.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .