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.
FWIW - I had a similar problem and I'm not sure if this alleviated it (beyond the permission mod): Closing Eclipse that was using the branch with this problem.
git reset --hard
Worked for me
When you have to unlink file, you have to have permission 'w' for directory, in which file is, not for the file...
Pulling may have created local change.
Add your untracked file:
git add .
Stash changes.
git stash
Drop local changes.
git stash drop
Pull with sudo permission
sudo git pull remote branch
sudo chown -R $USER:$USER .
Did the job for me.