Wayne Morris
Wayne Morris

Reputation: 113

Retaining Group Permissions with a Git Pull

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.

Upvotes: 4

Views: 1415

Answers (1)

Joe Atzberger
Joe Atzberger

Reputation: 3306

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.

Upvotes: 1

Related Questions