一种限制 Git 分支访问的方法? [英] A way to restrict Git branch access?

查看:24
本文介绍了一种限制 Git 分支访问的方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 git 存储库中有四个分支,使用 GitHub 进行管理:

I have four branches in my git repository, which is managed using GitHub:

  • 生产
  • 分期
  • 大师
  • [人名]-发展

有没有办法限制对单个分支的写访问权限([人名]-development)?我该怎么做?

Is there a way to restrict write access to only a single branch ([person's name]-development)? How would I do this?

作为参考,一个类似的问题:如何编写一个 git hook 来限制写入分支?.

For reference, a similar question: How to write a git hook to restrict writing to branch?.

推荐答案

使用 GitHub 时,最好的选择是让每个开发人员拥有自己的主存储库分支.每个人都推送到他们自己的存储库,并且对主存储库具有推送访问权限的人处理从每个开发人员的存储库中提取的内容.这是大多数开源项目的工作方式.

When using GitHub, your best option would be for each developer to have their own fork of the master repository. Everybody pushes to their own repository and somebody with push access to the master repository handles pulling from each developer's repository. This is how most open source projects work.

如果使用自己的 Git 服务器,应该可以使用钩子来防止用户推送到错误的分支.

If using your own Git server, it should be possible to use hooks to prevent users from pushing to wrong branches.

这篇关于一种限制 Git 分支访问的方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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