git Gerrit - 如何禁止直接推送到“主”但允许其他分支
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16238368/
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
Gerrit - how to disallow direct push to "master" but allow to other branches
提问by Tomasz Mielcarz
I want to set up configuration described below:
我想设置如下所述的配置:
Registered user can not push his changes directly to master. He has to push these changes for review:
git push origin master
- it should be rejected by Gerrit (origin = Gerrit)git push origin HEAD:refs/for/master
- it should be allowed by GerritRegistered user can create a new branch. This branch will be treated as a backup and a way of cooperation between two or more developers so it shouldn't be reviewed.
git push origin xyz_abc
- it should be allowed by Gerrit
注册用户不能将他的更改直接推送给 master。他必须推动这些变化以供:
git push origin master
- 它应该被 Gerrit 拒绝(来源 = Gerrit)git push origin HEAD:refs/for/master
- 应该被 Gerrit 允许注册用户可以创建一个新的分支。该分支将被视为两个或多个开发人员之间的备份和合作方式,因此不应对其进行。
git push origin xyz_abc
- 应该被 Gerrit 允许
How should I configure Gerrit
to achieve such functionality ?
我应该如何配置Gerrit
来实现这样的功能?
回答by Seb Charrot
There are no good instructions anywhere, so thought I'd document the steps here.
任何地方都没有好的说明,所以我想我会在这里记录步骤。
1. Navigate to your project's Access page
1. 导航到您项目的访问页面
Projects > List > your_project > Access
项目 > 列表 > your_project > Access
2. Edit Access
2. 编辑权限
Click the Edit button
单击编辑按钮
3. Add Reference to refs/heads/*
3. 添加对 refs/heads/* 的引用
This is the reference for all direct pushes. We're going to configure who can do what to this path.
这是所有直接推送的参考。我们将配置谁可以对这条路径做什么。
Click "Add Reference" and type in 'refs/heads/*' (no quotes)
单击“添加引用”并输入“refs/heads/*”(无引号)
4. Deny the "Push" permission
4.拒绝“推送”权限
The Push permission is the one which controls who can make direct pushes. Merge pushes and pushes to Gerrit will still be allowed (see notes below).
推送权限是控制谁可以直接推送的权限。合并推送和推送到 Gerrit 仍然是允许的(见下面的注释)。
- Click "Add Permission" and select "Push".
- Select the user group you want to deny push from (you can type in "Registered Users" if you want to block everyone)
- Choose "DENY" from the dropdown that appears once you've added your user group
- 单击“添加权限”并选择“推送”。
- 选择你想拒绝推送的用户组(如果你想阻止所有人,你可以输入“注册用户”)
- 添加用户组后,从出现的下拉列表中选择“拒绝”
5. Save Changes
5. 保存更改
And you're done. The finished config should look something like this:
你已经完成了。完成的配置应该是这样的:
Note
笔记
If this doesn't work, make sure you have the Push permission set to ALLOW on refs/for/refs/* - this is the permission which allows pushes to Gerrit.
如果这不起作用,请确保您在 refs/for/refs/* 上将 Push 权限设置为 ALLOW - 这是允许推送到 Gerrit 的权限。
回答by mrutyunjay
AFAIK you can set up permissions for every repo/project in gerrit. For example who can push / who can force push / who can approve your changes and all that. Check below link if it is usefull :
AFAIK 您可以为 gerrit 中的每个存储库/项目设置权限。例如,谁可以推送/谁可以强制推送/谁可以批准您的更改等等。检查以下链接是否有用:
回答by robinr
If there are many branches you can use namespaces (e.g. dev/*) for branches and set access control for these namespaces.
如果有很多分支,您可以为分支使用命名空间(例如 dev/*)并为这些命名空间设置访问控制。