git——为某些用户锁定主分支?

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

git -- locking master branch for some users?

gitbranchgit-branchbranching-and-merging

提问by aurora

I would like to force other team-members to not work on the master-branch but on a development branch. we have a central git-repository where we push our work into. i would like to know if it's possible to block users from pushing changes to the master-branch but only allow certain users to do so.

我想强迫其他团队成员不要在主分支上工作,而是在开发分支上工作。我们有一个中央 git 存储库,我们将工作推入其中。我想知道是否可以阻止用户将更改推送到主分支,但只允许某些用户这样做。

I would like to have the following "workflow"

我想要以下“工作流程”

  • development is always only done with a development-branch
  • the release-manager is responsible for the master branch and only he is allowed to merge stuff from a development branch into the master and push it to the master-branch on the central repository to.
  • 开发总是只用一个开发分支来完成
  • 发布经理负责主分支,只有他被允许将开发分支中的内容合并到主分支并将其推送到中央存储库上的主分支。

Is this possible and how can I achieve this?

这是可能的,我怎样才能做到这一点?

采纳答案by ephemient

See man githooks: In the shared repo, you can create a $(git rev-parse --git-dir)/hooks/pre-receiveor $(git rev-parse --git-dir)/hooks/updatescript that verifies what your users are trying to push to which refs. Git comes with a update-paranoidexample hook enforcing per-ref ACLs.

请参阅man githooks:在共享存储库中,您可以创建一个$(git rev-parse --git-dir)/hooks/pre-receive$(git rev-parse --git-dir)/hooks/update脚本来验证您的用户尝试推送到哪些引用。Git 附带了一个更新偏执示例钩子,用于强制执行每个引用 ACL。

回答by I GIVE CRAP ANSWERS

My low level approach would simply be to let the RM be the only one with SSH keys to push to the repository everyone else use as the master baseline. That way, nobody but the RM can push to master - yet everybody can work since they have their own local development branches and devs can share among themselves the branches they like.

我的低级方法只是让 RM 成为唯一一个拥有 SSH 密钥的人,可以将其他人用作主基线的存储库推送到存储库。这样,除了 RM 之外没有人可以推动掌握 - 但每个人都可以工作,因为他们有自己的本地开发分支,开发人员可以在他们之间共享他们喜欢的分支。

The next step is to make a cooking pot tester for the things that will go into master soon. This pot is normally called nextor dev. The idea is, that the more impact a branch has, the longer it cooks before a merge to master. This gives the RM full control over what branches should graduate and still gives everyone a heads-up.

下一步就是为即将进入掌握的东西制作一个烹饪锅测试仪。这个锅通常被称为nextdev。这个想法是,一个分支的影响越大,它在合并到 master 之前烹饪的时间就越长。这让 RM 可以完全控制应该毕业的分支,并且仍然让每个人都提前知道。