Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git, How to change a bare to a shared repo?

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?

like image 891
bottleboot Avatar asked Jan 16 '12 16:01

bottleboot


People also ask

How do I initialize a git repository with shared mode?

Specify that the Git repository is to be shared amongst several users. This allows users belonging to the same group to push into that repository. When specified, the config variable "core. sharedRepository" is set so that files and directories under $GIT_DIR are created with the requested permissions.


1 Answers

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):

[receive]     denyNonFastforwards = true 

Note: In order to decide whether you want denyNonFastforwards: This option means a merge never happens in the shared repository, which, in turn, means there is never a merge conflict on the shared repository. Instead the push is rejected forcing the user to do the merge in their local repository where it's much easier to fix and where it doesn't interfere with other people's use of the shared repo.

like image 57
miku Avatar answered Oct 11 '22 10:10

miku