Home > Back-end >  Is it possible to configure Git to set global write permissions when pushing to a filesystem remote?
Is it possible to configure Git to set global write permissions when pushing to a filesystem remote?

Time:01-19

Consider a git repository set up with a local filesystem remote, by user A as follows:

git init .
git remote add origin /var/git/my_project.git

touch X
git add X
git commit -m "My first commit"
git push origin master

If user B attempts to clone and then push, they will sometimes run into a permissions error because they cannot write to /var/git/my_project.git. User B could fix this by using sudo powers to change permissions on the remote:

sudo chmod 777 /var/git/my_project.git

Unfortunately, as soon as user B pushes, user A will have the same permissions problem.

How can I configure Git for both user A and user B such that when they push to the local filesystem remote, they will leave the permissions globally writeable?

(Note that I am aware of the security implications, but I am assuming only trusted users are able to login to the system in the first place.)

CodePudding user response:

Add both users to a git user group, change the repository files to be writable by that group.

CodePudding user response:

We were using a similar configuration at my office before moving to a GitLab server, and the way we solved it was to have default ACLs giving group read/write/execute to any new files created under the repo, initialized with ACLs granting those access on all files.

Repo access was controlled by membership in a linux group for the project, with the ACLs and default ACLs granting access to that group.

CodePudding user response:

I have not tested it, but you could try to create the repository with the --shared option:

git init --shared=0777

Where, for example, 0777 represents the permissions in the octal format.

  •  Tags:  
  • Related