Why does git fail on push/fetch with “Too many open files”

I’m encountering an issue with Git where I’m receiving the following message:

> git fetch
error: cannot create pipe for ssh: Too many open files
fatal: unable to fork

The System Administrators have increased my file limit, but it has not corrected the issue. Additionally, I don’t have an issue with creating new files with vi.

  • Using conditional configuration files with Git
  • How do I set default aliases or other configuration for my git repository?
  • Can't see remote branch, problems with .git/config?
  • How to configure kdiff3 instead of emerge as a git mergetool?
  • Is storing FTP credentials in git-ftp settings in repository insecure?
  • Why does git difftool use git diff instead?
  • When trying to push a new branch, I get a similar message:

    git push origin test_this_broken_git
    error: cannot create pipe: Too many open files
    fatal: send-pack: unable to fork off sideband demultiplexer

    Could somebody answer exactly why this is happening? I have not made any recent changes to my git config and have verified that manually.

  • How do I import a new release of a project into my git repository?
  • Using Git For Community-Oriented Website Content Revision System
  • Git patch of empty commits
  • Faking a git repository for testing
  • How to merge branches with different case on windows in GIT?
  • Hudson(Jenkins) and remote git repository get permission denied
  • One Solution collect form web for “Why does git fail on push/fetch with “Too many open files””

    There are two similar error messages:

    EMFILE: Too many open files
    ENFILE: Too many open files in system

    It looks like you’re getting EMFILE, which means that the number of files for an individual process is being exceeded. So, checking whether vi can open files is irrelevant—vi will use its own, separate file table. Check your limits with:

    $ ulimit -n

    So on my system, there is a limit of 1024 open files in a single process. You shouldn’t need to ask your system administrator (please don’t use the acronym SA, it’s too opaque; if you must abbreviate, use “sysadmin”) to raise the limit.

    You may wish to check which files Git opens by running Git under strace.

    This could be a bug in Git or in a library, or it could be you’re using an old version of something, or it could be something more bizarre. Try strace first to see which files it opens, and check whether Git closes those files.

    Update from Hazok:

    After using the above recommendations, it turns out the error was caused by too many loose objects. There were too many loose objects because git gc wasn’t being run often enough.

    Git Baby is a git and github fan, let's start git clone.