I’ve just got my first VPS & have set up NGinx, Ruby, Rails & Gitolite.
I can push and pull fine. However, once I push when I visit the URL I get a 403 forbidden error. The files locally are 755 but it seems Git is not storing those.
I’ve found a couple of posts discussing this (including this one: git deploying project – file permissions – (chmod)) and the answer seems to be to add a CHMOD 755 to the post-receive hook.
My post-receive currently looks like:
#!/bin/sh
GIT_WORK_TREE=/www/newrails git checkout -f
chmod 755 -R /www/newrails
And I have done chmod +x post-receive.
However when I push I get the error: remote: chmod: changing permissions of /www/newrails: Operation not permitted
How can I go about making it work, either through making the chmod in the hook have the permissions to run, or by some other means?
Try making the
chmodoperate on the contents of the folder rather than the folder itself:What’s probably happening is that the user the hook is running as (generally the user you’re using to ssh in for Git access) has permission to write into the folder, but not permission to change modes for the folder itself.