Why git doesn't work on push / fetch with "Too many open files"
I am having a problem with Git where I get the following message:
> git fetch error: cannot create pipe for ssh: Too many open files fatal: unable to fork System administrators have increased the file limit, but it did not fix the problem. Also, I have no problem creating new files with vi.
When I try to push a new branch, I get a similar message:
git push origin test_this_broken_git Error: cannot create channel: too many open files fatal: send-pack: cannot unlock sideband demultiplexer
Can anyone answer exactly why this is happening? I did not make any changes to my Git configurator and checked it manually.
There are two similar error messages:
EMFILE: Too many open files ENFILE: Too many open files in system
It looks like you are getting EMFILE , which means that the number of files for a particular process is exceeded. Thus, checking whether vi open files does not matter - vi will use its own separate file table. Check your limits:
$ ulimit -n 1024
So, on my system there is a limit of 1024 open files in one process. You do not need to ask your system administrator (do not use the abbreviation SA, it is too opaque, if you have to reduce, use "sysadmin") to increase the limit.
You can check which Git files are opened by running Git under strace .
It could be a bug in Git or in a library, or maybe you are using an old version of something, or it could be something weirder. Try strace first to see what files it opens and see if Git closes these files.
Update from Hazok:
After using the above recommendations, it turns out that the error was caused by too many lost objects. There were too many free objects because git gc was not executed often enough.