error: cannot fork() for status: Resource temporarily unavailable (git)

Solution 1:

The fork() system call should only fail (with that error) if there are too many processes running. See man 2 fork for details.

Rebooting should clear up the problem.

I'll speculate that maybe there are a lot of processes that haven't fully exited while debugging an iOS application.

Running the below line will show the three largest number of processes executing the same command (and how may processes are running those commands) to give an indication of what command is using up all the processes:

ps -efwww | awk '{print $8}' | sort | uniq -c | sort -n | tail -3

Solution 2:

I had this issue just now. It was due to corruption in my git directory after copying it across disks. Git is a combination of small unix tools forking each other. Running git status was causing git to go spiralling downwards into an infinite recursion of processes, running into my system's process limits ("max user processes" in ulimit).

In my particular instance I had submodules, which involve hardlinking back the parent git repository, so removing the submodule and reinitializing fixed my issue.

You could also try doing a git clone of your repository somewhere else.

Another more drastic option would be delving into a copy of the .git directory and cleaning up all but the packs, objects and refs. You can preserve the working tree by copying it back over the top after the git repo is sane again.

Good luck!