如何在 git 存储库上正确使用组文件权限? [英] How to use group file permissions correctly on a git repository?

查看:18
本文介绍了如何在 git 存储库上正确使用组文件权限?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在通过文件路径访问共享的 git 存储库,出于各种原因,我现在将省略,使用 --shared=group 创建.

我们有各种 unix 组,但都共享一个公共组.如果我在 git 存储库上运行 chgrp -R,每个人都可以从中读取,但是如果有人更频繁地写入它,则会创建不使用公共组的新文件.

这个问题似乎是因为我们的主要组不是共享组,如果我们运行 newgrp 似乎一切正常.

但是这种方法存在问题;newgrp 很慢,它会生成一个新的 shell,这让我觉得在 .bash_profile 中调用它是个坏主意,甚至没有考虑我们是否希望 所有 我们的新文件都使用共同组.不过,在执行任何 git 工作之前依靠内存来运行它似乎也是一种灾难.

所以...有什么建议吗?

解决方案

您需要设置 setgid 在小组中也是如此.

<前>chgrp -R 组/path/to/repofind/path/to/repo -type d -print0 |xargs -0 chmod g+s

We're accessing a shared git repository via file paths, for various reasons I'll omit for now, created with --shared=group.

We have various unix groups but all share a common group. If I run a chgrp -R on the git repository everyone can read from it, but if someone writes to it more often than not new files are created which do not use the common group.

This problem appears to be because our primary group is not the shared one and if we run a newgrp all seems to work well.

There are issues with this approach though; newgrp is slow and it spawns a new shell, which makes me think calling it in a .bash_profile would be a bad idea, without even considering whether or not we'd want all our new files to use the common group. Relying on memory to run it before doing any git work seems like a recipe for disaster too though.

So... any suggestions?

解决方案

You need to set the setgid bit on the group as well.

chgrp -R GROUP /path/to/repo
find /path/to/repo -type d -print0 | xargs -0 chmod g+s 

这篇关于如何在 git 存储库上正确使用组文件权限?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆