bash 将 GIT 存储库更改为共享
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7268560/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Change GIT repository to shared
提问by Vojtěch
Git allows to create a shared repository amongs a group:
Git 允许在组之间创建共享存储库:
git --bare init --shared=group
However - how can I change already existing repository to shared? I don't want to re-git-init it.
但是 - 如何将现有存储库更改为共享?我不想重新 git-init 它。
回答by Elazar Leibovich
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_DIRare created with the requested permissions. When not specified, git will use permissions reported by umask(2).
--shared[=(false|true|umask|group|all|world|everybody|0xxx)]
指定要在多个用户之间共享 git 存储库。这允许属于同一组的用户推送到该存储库。指定后,将设置配置变量“core.sharedRepository”,以便
$GIT_DIR使用请求的权限创建其下的文件和目录。如果未指定,git 将使用 umask(2) 报告的权限。
Therefore, in order to change the permission, chmodeverything to your liking, and set the core.sharedRepositoryin git configaccordingly:
因此,为了更改权限,chmod一切都按照您的喜好,并相应地设置core.sharedRepositoryin git config:
git config core.sharedRepository true
回答by Jan Wielemaker
To make a private bare repo group shared:
要共享一个私有的裸仓库组:
- Edit config and add
sharedRepository = groupto thecoresection - Fix permissions from inside the repo:
chgrp -R target-group .find . -type d | xargs chmod g+wsfind refs -type f | xargs chmod g+w
- 编辑配置并添加
sharedRepository = group到该core部分 - 从 repo 内部修复权限:
chgrp -R target-group .find . -type d | xargs chmod g+wsfind refs -type f | xargs chmod g+w

