Take the 2-minute tour ×

So this is how I set up my project:

git init --bare

Later I learned that if you want to work on a project with multiple users this is how I should have done it:

git init --bare --shared

Now I tried to work like that and luckily we are in the beginning so I could set up git again. I still wonder though when you're in the middle of a project you can't do that. Is there a way that i can change a bare repo to a shared one?

share|improve this question
add comment

4 Answers

up vote 17 down vote accepted

Since the --shared option just sets the permissions on everything in the repository to group-writable you could do this manually later:

$ chmod -R g+w the/repo/path

Plus, add

sharedrepository = 1

under the [core] section in .git/config. Shared repos also have the following receive option defined by default (which you may or may not want):

    denyNonFastforwards = true
share|improve this answer
Aha ok! Good to know, wish I had asked this before. Thanks! –  bottleboot Jan 16 '12 at 16:46
Ok, I see! I just read the @jørgensen answer which confirms that. Stackoverflow should have a combined answer button :D! Thank you all a lot that was very enlightening! –  bottleboot Jan 16 '12 at 16:53
Didn't work for me. It required chmod -R g+s .... A fresh git init --bare --shared will have the group rights "rws". (Ubuntu 12.04) –  Unapiedra Jan 29 at 15:11
add comment

Besides chmod -R g+w, you also need to edit (.git/)config and set core.sharedRepository = .... For ..., there are a handful of values, described in git-init(1).

share|improve this answer
Ok! That seems to completes my suspicion that I also needed to change the config. Thanks! –  bottleboot Jan 16 '12 at 16:49
add comment

Probably if you try to share an existent repository, you may have lots of different users commits.

1.If you have super user permission, you can go forward and change all permissions by yourself using the step two, in any-other case you will need to ask all users with objects created with their users, use the following command to know who they are:

$ ls -la | awk '{print $3}' | sort -u 
<your user_name>
<his user_name>

2.Now you and all file's owner users will have to change those files permission, doing:

$ chmod -R 774 .

3.After that you will need to add a new property that is equivalent to --shared=group done for the new repository, according to the documentation, this make the repository group-writable, do it executing:

$ git config core.sharedRepository group
share|improve this answer
add comment

If you're trying to share the repository off of the the host it is on, there are additional configuration steps you have to make (ssh stuff).



share|improve this answer
I don't think that is what we're doing for this current repo. Thanks though! –  bottleboot Jan 16 '12 at 16:46
add comment

Your Answer


