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

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

问题描述

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

错误信息:

<块引用>

错误:您不能将代码推送到此项目的受保护分支.
...
错误:未能将一些 refs 推送到 ...

解决方案

没有问题 - 一切正常.

在 GitLab 中,一些分支可以受到保护.默认情况下,只有维护者/所有者用户可以提交受保护的分支(请参阅

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

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

从 GitLab 9.0 开始

与 GitLab 9.3 类似,但无需点击展开"——一切都已展开:

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

GitLab 9.0 前

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

然后点击取消保护"或开发者可以推送":

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 message:

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.

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.

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

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.)

Since GitLab 9.3

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

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

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.

Since GitLab 9.0

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".

Pre GitLab 9.0

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天全站免登陆