在 GitLab 上强制推送至 master 分支,报错:remote GitLab You are not allowed to force push code to a protected branch on this project. 的分析解决

1、在 GitLab 上强制推送,报错:remote GitLab You are not allowed to force push code to a protected branch on this project. 。如图1

在 GitLab 上强制推送,报错:remote GitLab You are not allowed to force push code to a protected branch on this project.

图1

git.exe push --force-with-lease --progress "origin" master:master
Total 0 (delta 0), reused 0 (delta 0)
remote: GitLab: You are not allowed to force push code to a protected branch on this project.
To https://gitlab.chinamcloud.com/php/yii2-app-advanced.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://gitlab.chinamcloud.com/php/yii2-app-advanced.git'


git 未能顺利结束 (退出码 1) (3109 ms @ 2020/06/29 16:09:02)

2、查看 GitLab – Members – Existing members and groups。Master,理论上是具有权限的。如图2

查看 GitLab - Members - Existing members and groups。Master,理论上是具有权限的。

图2

3、Repository Settings – Protected Branches – Allowed to push。为:Masters。如图3

Repository Settings - Protected Branches - Allowed to push。为:Masters。

图3

4、Repository Settings – Protected Branches – Allowed to push。调整为:Developers + Masters。如图4

Repository Settings - Protected Branches - Allowed to push。调整为:Developers + Masters。

图4

5、再次推送,报错:error: failed to push some refs to。如图5

再次推送,报错:error: failed to push some refs to。

图5

6、查看提交记录,重置至 master 分支的合并前的最新版本。如图6

查看提交记录,重置至 master 分支的合并前的最新版本。

图6

7、Repository Settings – Protected Branches。删除分支 master,点击按钮 Unprotect。如图7

Repository Settings - Protected Branches。删除分支 master,点击按钮 Unprotect。

图7

8、再次推送,推送成功。还原第 7 步骤、第 4 步骤所做的操作。如图8

再次推送,推送成功。还原第 7 步骤、第 4 步骤所做的操作。

图8

git.exe push --force-with-lease --progress "origin" master:master
Total 0 (delta 0), reused 0 (delta 0)
To https://gitlab.chinamcloud.com/php/yii2-app-advanced.git
+ a80db96...8fb427a master -> master (forced update)

成功 (2921 ms @ 2020/06/29 16:42:52)

原创文章,作者:carmelaweatherly,如若转载,请注明出处:https://blog.ytso.com/tech/webdev/181536.html

(0)
上一篇 2021年11月1日 03:19
下一篇 2021年11月1日 03:19

相关推荐

发表回复

登录后才能评论