git - 如何锁定git repos master分支?

标签 git hook pre-commit-hook

我需要锁定 git 仓库的主分支。我尝试了预提交 Hook ,但它们只是客户端 Hook ,但我想锁定大多数用户的主分支。谁能告诉我 git 上的预接收 Hook 的步骤(我使用 github)或锁定 master 的任何更好的方法?

PS:我们的 github 许可版本不支持 gitolite。

最佳答案

GitHub 许可意味着“GitHub:enterprise”,正如文章“Migrating from GitHub:FI”中所解释的那样:不允许自定义 Hook
(另见“How can I add a custom git hook to a GitHub Enterprise repo?”)

所以我会采用不同的方法,在该服务器上维护的不是一个存储库,而是两个存储库(第二个是第一个的克隆)。

每个人都可以推送到第一个,但只有选定的用户可以推送到第二个,这允许他/她从第一个 repo 中选择有资格推送到第二个的内容。
因此,“repo2”在某种程度上代表您的“master”,而“repo1”代表所有其他用户可以推送的任何其他分支到。
这个有点类似这个GitHub gist article .

I suggest separating the release engineering team into their own organization.
The developers will have to fork all of the repositories residing in the release engineering team.
The developers will be able to commit to master within their organization.
They must send pull requests in order to get their commits into the release_engineering organizations.

Note: It will take some time to convince the customer that committing to the master branch of acme_developers/foobar is distinct from committing to the master branch of acme_release_engineering/fooba.

关于git - 如何锁定git repos master分支?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12229810/

相关文章:

git - git中tracking的含义

git - 为什么 git 认为我有一个稀疏 checkout ? "You are in a sparse checkout with 100% of tracked files present."

php - 每种电子邮件类型的 Woocommerce 不同标题

windows - Hook 特定进程的注册表访问的简单方法

class - 在 drupal 8 的标题区域中添加自定义类

svn - 需要用户在控制台中键入 'y/n' 的颠覆预提交 Hook ?

php - 如何将私有(private) github 存储库添加为 Composer 依赖项

git - 重命名 merge 的提交而不丢失该提交的父级

Git Pre-Commit 使用sed 动态注入(inject)分支名

validation - 如何在没有变量插值的情况下验证 Jinja 语法