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
sudo chmod -R ug+w .;
This command would fix the issue. It gives write permissions to the folder.