如何让多个用户可以访问我的本地 Git 存储库?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4369735/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 04:48:28  来源:igfitidea点击:

How can I make my local Git repository accessible for multiple users?

gitpermissionsfile-permissions

提问by 12345

I want to create a git repository and allow all users to have access to it. I tried initializing it by:

我想创建一个 git 存储库并允许所有用户访问它。我尝试通过以下方式初始化它:

git init --shared=all 

However when I change the user and do a git status, I get the following error:

但是,当我更改用户并执行 a 时git status,出现以下错误:

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

Is this supposed to happen? I access the repo on my local file-system and not via SSH.

这是应该发生的吗?我访问本地文件系统上的 repo,而不是通过 SSH。

回答by Fred Foo

Apparently, --shared={all|world|everybody}is broken in recent Git. Use octal permissions:

显然,--shared={all|world|everybody}在最近的 Git 中被破坏了。使用八进制权限:

git init --shared=0777

回答by Jed Schneider

you need to specify in the shared option which group of users you want to share with. http://www.kernel.org/pub/software/scm/git/docs/git-init.html

您需要在共享选项中指定要与其共享的用户组。http://www.kernel.org/pub/software/scm/git/docs/git-init.html

you also need to make sure all the users you want to share with are in the same group.

您还需要确保要与之共享的所有用户都在同一组中。

回答by Won Jun Bae

Alternatively, you can try to avoid setting the permission level to 777,

或者,您可以尽量避免将权限级别设置为 777,

change the ownership
sudo chown -v -R username:groupname sprout
chmod -R g+w .git/*