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/<website> git checkout -f
But when I make a push from my local machine to the git repository in the server, I get the following error messages:
remote: error: unable to unlink old '<file>' (Permission denied)
This appears many times over, one error message for almost every file.
However I have a README.txt file that I'm able to change using git, here are its permissions:
-rw-r--r-- 1 <serverusername> <serverusername> 2939 Aug 2 10:58 README.txt
But other files with exactly the same owner and same permissions, give me that error.
In another local repository for another website, I have the files with my local machine username as owner, and when I push to the remote server it respects the remote server owner of the files and works like a charm.
Obviously it seems a permissions related error, but I can't find a way to fix it, any suggestions?
When you have to unlink file, you have to have permission 'w' for directory, in which file is, not for the file...
sudo chmod -R ug+w .;
This command would fix the issue. It gives write permissions to the folder.
If you are using any IDE most likely the problem is that file was used by some process. Like your tomcat might be using the file. Try to identify that particular process and close it. That should solve your problem.
I think the problem may be with the ownership to the folder so set it to the current user ownership
sudo chown -R your_login_name /path/to/folder
You can find the solution [here][1]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With