$ git push cjxtOrigin master:master
To http://cjxt.tools.bigcloudsys.cn ... rt/pc/pc_client.git
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'http://cjxt.tools.bigcloudsys.cn/gitlab/cloudTecSupport/pc/pc_client.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
移动库和本地库有冲突,强制推送
$ git push -f cjxtOrigin master:master
Enumerating objects: 1779, done.
Counting objects: 100% (1490/1490), done.
Delta compression using up to 4 threads
Compressing objects: 100% (803/803), done.
Writing objects: 100% (1296/1296), 2.31 MiB | 2.32 MiB/s, done.
Total 1296 (delta 1018), reused 751 (delta 493), pack-reused 0
remote: Resolving deltas: 100% (1018/1018), completed with 148 local objects.
remote: GitLab: You are not allowed to force push code to a protected branch on this project.
To http://cjxt.tools.bigcloudsys.cn ... rt/pc/pc_client.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'http://cjxt.tools.bigcloudsys.cn/gitlab/cloudTecSupport/pc/pc_client.git'
这是因为项目分支master设置了保护所致,是为了防止别人乱提交代码设置的
可以到项目的Settings页面下找到 Protected Branches,有如下两种解决方法
1.可以直接点该分支旁的Unprotect按钮,解除保护,但是这种方法不推荐
2.第二种方法是在Allowed to push下选择允许那些角色或具体那些用户可以提交,在这里可以选择你自己