skip to Main Content

Is it possible to deploy to the server via git but keeping the DocumentRoot permissions at username:www-data? How can I let use git another user then root and keep the www-data group for the files?

Right now I get after any push the files changed to root:root and I have to login to remote and change the permissions manually each time.

2

Answers


  1. Chosen as BEST ANSWER

    I just had to change the ownership (user1:user1) of the git repository to the same as the one for the directory defined as the DocumentRoot in the virtual hosts config.

    Additionally I had to enable libapache2-mpm-itk (as I want to split all the sites on the machine from each other):

    https://cloudkul.com/blog/apache-virtual-hosting-with-different-users/

    https://packages.ubuntu.com/search?keywords=apache2-mpm-itk


  2. Git does not change file permissions or ownership. It just doesn’t store permissions.Permissions are changed to whatever your user has. Just like with any file creation.

    Git supports two permission sets: executable bit on and executable bit off. Nothing else. Ownership information is not stored at all.

    If you want specific permissions, you’ll need to do it manually.

    As another workaround you can use git hooks or can use a separate tool to do it for you

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search