Search code examples
macosgitcentossuphp

How do I force Git to use the owner and permissions of the enclosing folder?


I have been noticing that when I pull changes to my server that it automatically adds group write access to the files that are changed. However since I am using suPHP that causes a 500 error, so I am needing to disregard any permissions and ownership that the Git repo may have and replace it with the proper permissions that the folder itself has.

EDIT: suphp requires maximum permissions of 644 for files and 755 for directories, to help protect the user's files from modification. It is a patch to PHP that works wit Suhosin.

I work with a localhost environment, push to staging and that is when I get the errors because staging is a clone of the production environment.


Solution

  • I ended up using the post-merge hook and running a chmod -R g-w . in a bash script. This helped make sure that it never added any other write files that would cause the server to 500 error out.