[ACCEPTED]-Using Git without Sudo in many accounts-sudo
If I understand your question correctly, you 10 need grant several *nix user accounts write 9 access to the same git repository. Using 8 the --share
command line argument for git init
should enable 7 this. The GitWiki has a few words to say about this. This should do the 6 trick:
git --bare init --shared=all
If you have already created your repository, you 5 might be able to convert it to a "shared 4 repository" by throwing this command:
git repo-config core.sharedRepository true
in 3 your repository, as mentioned in a blog post at moserei.de.
2014 update: This 2 is still possible but the command has changed 1 from repo-config to config.
git config core.sharedRepository true
Git is meant to be distributed. So, every 4 user should be having a separate repository 3 of his/her own. The above method contradicts 2 this methodology. Apart from that, I suspect 1 the permissions of the .git
directory.
I would guess the ownership of the .git
directory 7 are the problem.
You shouldn't use one source 6 tree from different users - it's likely 5 to lead to problems.
The git
executable is not 4 the issue. It should be owned by root, and 3 have 755 permissions. (-rwxr-xr-x
)
In other words you 2 can use git from multiple accounts, but 1 you shouldn't share a single working directory.
Having the permissions of any executable 18 set so that a normal user can overwrite 17 the executable is a considerable security 16 risk. (Try overwriting /usr/bin/git
with a shell script 15 that calls rm -rf $HOME
.)
Change the permissions back 14 to 755 and make git owned by root:root again. (Ubuntu's 13 package manager would reset the permissions 12 on the next upgrade anyhow unless you used 11 dpkg-statoverride(8)
)
I agree with those who say that it may 10 not be a good idea to have multiple users 9 share one git repository. If you still think 8 that it is necessary, consider setting up 7 a new group, chgrp
the directory holding the 6 repository and all the files therein to 5 that group andset the setgid bit on the 4 directories. (The --shared
parameter to git init
may do 3 some of this for you, too.) Then, add all 2 the users to the group that should have 1 commit rights.
You can verify members using
members groupname
Then you can 2 set the permission level for the username:groupname 1 pair,
change the ownership
sudo chown -v -R username:groupname sprout
chmod -R g+w .git/*
More Related questions
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.