当我在项目中拥有开发人员访问权限时,我将代码推到git时遇到了一个问题,但当我拥有主访问权限时,一切都很好。问题从何而来?如何解决呢?
错误信息:
错误:不允许将代码推送到此项目上受保护的分支。 ... 错误:failed to push some refs to…
当我在项目中拥有开发人员访问权限时,我将代码推到git时遇到了一个问题,但当我拥有主访问权限时,一切都很好。问题从何而来?如何解决呢?
错误信息:
错误:不允许将代码推送到此项目上受保护的分支。 ... 错误:failed to push some refs to…
当前回答
替代解决方案,使用GitLab 13.11(2021年4月)
Force push option for protected branches It’s best practice to prevent force push on Git repos, but exceptional cases may occasionally require it. Temporarily removing branch protections in order to conduct a force push may not always be ideal as it requires maintainer access, and causes the settings for branch protection to be lost. GitLab 13.11 introduces a new Allow force push setting for protected branches, which enables users in the Allowed to push list to force push. See Documentation and Issue.
其他回答
我的存储库也遇到了同样的问题。我是仓库的主人,但我犯了这样一个错误。
我已经保护了我的项目,然后再次重新保护,错误就消失了。
在我之前的推送和有问题的推送之间,我们升级了gitlab版本。我想是这次升级造成了这个bug。
当这个问题出现时,我正在使用Windows。
这个错误很奇怪,因为它发生在我输入用户名和密码之前。如果有一个缓存或者类似的东西呢?我在网上找到了答案,并在gitlab的支持论坛上找到了这个答案:
我打开“控制面板=>用户帐户=>管理您的凭证=> Windows凭证” 我发现了两个https://@github.com和一个是错误的用户。我删除了它,在下一个“git推送”,我被重新提示,并提供了正确的凭据,它工作! 一些其他注意事项-这可能发生在任何git远程。
在Windows凭证中,我发现了一个旧帐户的两个GitLab条目。我删除两者,现在它工作!
面板:
替代解决方案,使用GitLab 13.11(2021年4月)
Force push option for protected branches It’s best practice to prevent force push on Git repos, but exceptional cases may occasionally require it. Temporarily removing branch protections in order to conduct a force push may not always be ideal as it requires maintainer access, and causes the settings for branch protection to be lost. GitLab 13.11 introduces a new Allow force push setting for protected branches, which enables users in the Allowed to push list to force push. See Documentation and Issue.
对我来说,问题是用户试图推送,但没有被邀请到项目中。我必须去项目信息>成员,并邀请成员作为开发人员,这样他们就可以访问推送。
我也遇到过类似的问题。然而,问题是存储库被意外归档了!您可以通过转到存储库(至少在Gitlab中)进行检查,它显示了以下消息“已存档的项目!”存储库和其他项目资源是只读的。”为了向它推送,我们必须解压缩它。