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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With