In the remote server I have a post-receive hook set up in order to make a git checkout of my repository:
#!/bin/sh GIT_WORK_TREE=/var/www/ git
I get this error, and other strange git errors, when I have a server running (in Intellij). Stopping the server and re-trying the git command frequently fixes it for me.