修复GitLab错误:“不允许您将代码推送到该项目上受保护的分支"? [英] Fix GitLab error: "you are not allowed to push code to protected branches on this project"?

查看:960
本文介绍了修复GitLab错误:“不允许您将代码推送到该项目上受保护的分支"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在项目中具有开发人员访问权限时,将代码推送到git时出现问题,但是在具有主访问权限的情况下一切正常.问题出在哪里?以及如何解决?

I have a problem when I push my codes to git while I have developer access in my project, but everything is okay when I have master access. Where is the problem come from? And how to fix it?

错误消息:

错误:不允许将代码推送到该项目上受保护的分支.
...
错误:无法将某些参照推送到...

error: You are not allowed to push code to protected branches on this project.
...
error: failed to push some refs to ...

推荐答案

没有问题-一切都按预期进行.

there's no problem - everything works as expected.

在GitLab中可以保护某些分支.默认情况下,只有维护者/所有者用户可以提交到受保护的分支机构(请参阅权限文档) . master分支默认情况下受保护-强制开发人员发出合并请求,以供项目维护人员先验证,然后再将其集成到主代码中.

In GitLab some branches can be protected. By default only Maintainer/Owner users can commit to protected branches (see permissions docs). master branch is protected by default - it forces developers to issue merge requests to be validated by project maintainers before integrating them into main code.

您可以在项目设置"中打开和关闭选定分支的保护(确切取决于GitLab版本-请参见下面的说明).

You can turn on and off protection on selected branches in Project Settings (where exactly depends on GitLab version - see instructions below).

在同一设置页面上,您还可以允许开发人员推入受保护的分支.启用此设置后,保护将仅限于拒绝需要git push --force的操作(变基等)

On the same settings page you can also allow developers to push into the protected branches. With this setting on, protection will be limited to rejecting operations requiring git push --force (rebase etc.)

转到项目:设置"→存储库"→受保护分支"上的扩展"

Go to project: "Settings" → "Repository" → "Expand" on "Protected branches"

我不太确定何时引入此更改,屏幕截图来自10.3版.

I'm not really sure when this change was introduced, screenshots are from 10.3 version.

现在,您可以选择允许哪些人合并或推送到选定的分支中(例如:您可以完全关闭对master的推送,强制通过合并请求对分支进行所有更改).或者,您可以单击取消保护"以完全删除分支的保护.

Now you can select who is allowed to merge or push into selected branches (for example: you can turn off pushes to master at all, forcing all changes to branch to be made via Merge Requests). Or you can click "Unprotect" to completely remove protection from branch.

类似于GitLab 9.3,但无需单击展开"-一切都已展开:

Similarly to GitLab 9.3, but no need to click "Expand" - everything is already expanded:

转到项目:设置"→存储库"→向下滚动到受保护的分支".

Go to project: "Settings" → "Repository" → scroll down to "Protected branches".

项目:设置"→受保护的分支"(如果您至少是给定项目的主").

Project: "Settings" → "Protected branches" (if you are at least 'Master' of given project).

然后单击取消保护"或开发人员可以推送":

Then click on "Unprotect" or "Developers can push":

这篇关于修复GitLab错误:“不允许您将代码推送到该项目上受保护的分支"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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