3

The company I work for is using Git for deployment and because of this it overwrites specific permissions and ownerships. What is the best way to make sure that the folder ownerships and permissions are preserved when a git pull is conducted?

I do development on OS X, using MAMP, push to a staging server which is a clone of the environment on production. When it reaches Staging I have to correct the permissions afterward but they are usually set to 664 instead of 644, causing issues with suPHP.

OpensaurusRex
  • 151
  • 3
  • 10

2 Answers2

2

Can you use one of the git hooks?

Probably the post-checkout hook.

slm
  • 7,615
  • 16
  • 56
  • 76
cjc
  • 24,916
  • 3
  • 51
  • 70
  • Would that work with git-pull? – OpensaurusRex Mar 09 '12 at 20:19
  • 1
    This isn't an answer, it is another question. Not helpful. Don't know why it was accepted. If it does work, then this questionable answer should be updated with an actual answer. Pretty please. – geoidesic Dec 13 '14 at 11:39
  • @geoidesic I added the final result in the below answer. It's been a while since I did this so forgive me if I am forgetting anything. – OpensaurusRex Oct 19 '22 at 15:22
1

The answer ended up being that I had to use the post-merge hook, after reading through the link that was provided by the other answer.

In the .git/hooks folder I created a file called post-merge and included the something like the following code:

#!/bin/sh
sudo chown -R opensaurusrex:staff .
sudo chmod 2775 .
sudo find . -type d -exec chmod 2775 {} \;
sudo find . -type f -exec chmod 0664 {} \;

I don't remember if I had to run it in a specific way to make sure that sudo worked properly. It should work if you replace #!/bin/sh with the current #!/bin/zsh for modern MacOSX distributions where they are using zsh instead.

OpensaurusRex
  • 151
  • 3
  • 10