Can‘t push refs to remote.Try running “Pull“first to integrate your changes.

问题

在使用git推送代码到远程的gitlab库时抛出,分支受保护(protected)错误信息。详细信息如下:
在这里插入图片描述

git push origin master:master
remote: GitLab: You are not allowed to push code to protected branches on this project.
To https://git.xxx.com/xxx/xxx.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to ‘https://git.xxx.com/xxx/xxx.git’

解决办法

1、进入到gitlab后台管理界面,查看当前项目的分支信息。如下图:
在这里插入图片描述
上图中,master分支存在一个绿色的标识(protected)标识,标识该分支是受保护的,不能推送代码。

2、点击gitlab的“Settings”> “Repository”,在打开的界面选择 “Protected Branches”项的“Expand”按钮。如下图:
在这里插入图片描述
3、在打开的界面可以看见master分支是在受保护的,我们只需要点击“unprotect”按钮,将master分支从受保护中移除。如下图:
在这里插入图片描述
到这里就解决了。。。

猜你喜欢

转载自blog.csdn.net/ksjdbdh/article/details/131826371
今日推荐