Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Retaining Group Permissions with a Git Pull

Tags:

git

I have a user:group owned by www-data. Whenever I do a pull to the server (in the cgi-bin directory), the modified files get changed from www-data to root.

I would like to know if there is a way to pull the content of the files from git while at the same time keep the user-group permissions unchanged after the pull has been executed.

Please advise. Thanks.

like image 326
Wayne Morris Avatar asked Nov 27 '25 15:11

Wayne Morris


1 Answers

This is because you are pulling as root. You would want to pull as the user intended to own the files. Of course, attaching credentials to your www-data account is not great for security, so you should probably use something like github's deploy keys (can pull code, but not push).

If you want to pull as www-data, you can su - www-data, but initially you will have problems since root already owns files and parts of the git index. You will want to chown -R www-data:www-data /path/to/dir so that your intended user can modify the repo and index during pulls.

Also you can use the sticky bit as suggested in comment.

like image 84
Joe Atzberger Avatar answered Nov 30 '25 06:11

Joe Atzberger