Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change GIT repository to shared

Tags:

git

bash

Git allows to create a shared repository amongs a group:

git --bare init --shared=group

However - how can I change already existing repository to shared? I don't want to re-git-init it.

like image 976
Vojtěch Avatar asked Sep 01 '11 09:09

Vojtěch


People also ask

How do I share a Git repository?

Under your repository name, click Settings. In the "Access" section of the sidebar, click Collaborators & teams. Click Invite a collaborator. In the search field, start typing the name of person you want to invite, then click a name in the list of matches.

How do I initialize a Git repository with share 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.


2 Answers

According to the documentation:

--shared[=(false|true|umask|group|all|world|everybody|0xxx)]

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. When not specified, git will use permissions reported by umask(2).

Therefore, in order to change the permission, chmod everything to your liking, and set the core.sharedRepository in git config accordingly:

git config core.sharedRepository true
like image 58
Elazar Leibovich Avatar answered Oct 19 '22 04:10

Elazar Leibovich


To make a private bare repo group shared:

  1. Edit config and add sharedRepository = group to the core section
  2. Fix permissions from inside the repo:
    • chgrp -R target-group .
    • find . -type d | xargs chmod g+ws
    • find refs -type f | xargs chmod g+w
like image 10
Jan Wielemaker Avatar answered Oct 19 '22 03:10

Jan Wielemaker