Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Git without Sudo in many accounts

Tags:

git

sudo

ubuntu

How can you use Git without Sudo in multiple accounts in one Ubuntu?

My Ubuntu has many accounts. The creation of new accounts has made Git inaccessible by me without sudo.

I changed the owner to be me, masi, and the group to be admin where the masi belongs to. I have the following permissions for Git

800 -rwxrwxrwx 1 masi admin 813744 2009-02-20 23:01 /usr/bin/git

I get the following message in trying to use Git

git status
fatal: unable to create '.git/index.lock': Permission denied

I run find . -iregex ".*index.l.* which returns no matches so there seems to be no index.lock in locking the system. I run the same command also with sudo unsuccessfully.

like image 884
hhh Avatar asked Sep 02 '09 11:09

hhh


People also ask

How do I prevent git from requiring Sudo on every git command?

Change the current working directory to your local project. List your existing remotes in order to get the name of the remote you want to change. Change your remote's URL from HTTPS to SSH with the git remote set-url command. Verify that the remote URL has changed.

Should I use Sudo with Git?

The Git command uses credentials and configuration stored in the current user's home directory; when you run as sudo , this code is going to be looking at the root home directory, not your home directory and thus miss this context. In most cases, it should not be necessary to use sudo .


2 Answers

If I understand your question correctly, you need grant several *nix user accounts write access to the same git repository. Using the --share command line argument for git init should enable this. The GitWiki has a few words to say about this. This should do the trick:

git --bare init --shared=all

If you have already created your repository, you might be able to convert it to a "shared repository" by throwing this command:

git repo-config core.sharedRepository true

in your repository, as mentioned in a blog post at moserei.de.

2014 update: This is still possible but the command has changed from repo-config to config.

git config core.sharedRepository true
like image 94
Jørn Schou-Rode Avatar answered Oct 12 '22 10:10

Jørn Schou-Rode


Git is meant to be distributed. So, every user should be having a separate repository of his/her own. The above method contradicts this methodology. Apart from that, I suspect the permissions of the .git directory.

like image 45
Alan Haggai Alavi Avatar answered Oct 12 '22 10:10

Alan Haggai Alavi