0

I have root owned files and other files in a directory and I would like to use git for version control of these files. Is it possible to use same git repo for files owned by root and non-root users or is it just asking for troubles?

I made a simple test where I created a repo as ordinary user, checked in and out some files and the checked in root owned files by using sudo git add, sudo git commit because ordinary user does not have read access to these files. After this .git/index is owned by root and ordinary user cannot run e.g. git add, git commit.

What is the recommended way to manage versions if files are owned by root and non-root users?

1 Answer 1

0

You can use core.sharedRepository to group to set permissions on a repository to be shared with a group. Then, set the setgid bit on the root of the repository and each directory under it, and change the group for each file and directory to a group that each user is a part of (or at least the non-root users).

That will ensure that Git writes all of the files in the tree to share permissions with a given group, and that the group for all files and directories will be the same: that of the containing directory.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.