如何设置不同用户只能看到某些部分的 git 存储库? [英] How to set up a git repository where different users can only see certain parts?

查看:36
本文介绍了如何设置不同用户只能看到某些部分的 git 存储库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你如何设置一个 git 存储库,让一些用户可以看到源代码的某些部分,而其他用户可以看到全部?我看过很多只授予某些用户提交访问权限的指南,但这些指南假设每个人都应该拥有读取权限.我也听说过 gitosis,但我不确定它是否支持这一点,而且它在一年多的时间里没有任何提交,所以我认为它已经死了.

How do you set up a git repository where some users can see certain parts of the source code and other users can see all of it? I've seen lots of guides for only giving certain users commit access, but these assume everyone should have read access. I've also heard of gitosis, but I'm not sure it supports this and it hasn't had any commits in over a year so I think it's dead.

推荐答案

简而言之:你不能.Git 是基于快照(至少在概念级别)的版本控制系统,而不是基于变更集的版本控制系统.它将项目(存储库)视为一个整体.历史是一个项目的历史,而不是单个文件历史的联合(它不仅仅是加入每个文件的历史).

In short: you can't. Git is snapshot based (at conceptual level at least) version control system, not changeset based one. It treats project (repository) as a whole. The history is a history of a project, not a union of single-file histories (it is more than joining of per-file histories).

在 contrib 中使用诸如 update-paranoid 钩子之类的钩子,或 VREFs gitolite 机制,你可以允许或禁止访问存储库,你可以允许或禁止访问单个分支.您甚至可以禁止任何更改指定子目录中内容的提交.但项目始终被视为一个整体.

Using hooks like update-paranoid hook in contrib, or VREFs mechanism of gitolite, you can allow or forbid access to repository, you can allow or forbid access to individual branches. You can even forbid any commits that change things in specified subdirectory. But the project is always treated as a whole.

好吧,您可以做一件事:将要限制访问的目录创建到子模块,并限制对该子模块存储库的访问.

Well, there is one thing you can do: make a directory you want to restrict access to into submodule, and restrict access to this submodule repository.

这篇关于如何设置不同用户只能看到某些部分的 git 存储库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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