Forcibly push to the master branch on GitLab, error: Remote GitLab you are not allowed to force push code to a protected branch on this Analysis of Project.
1. Force push on GitLab, and report an error: Remote GitLab you are not allowed to push code to a protected branch on this project. as shown in Figure 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 tohttps://gitlab.chinamcloud.com/php/yii2-app-advanced.git Git failed to end (exit code 1) (3109 ms @ 2020/06/29 16:09:02)
2. Check GitLab – Members – Existing Members and Groups. Master, in theory, has permissions. as shown in Figure 2
3. Repository settings – protected branches – allowed to push. for: masters. as shown in Figure 3
4. Repository settings – protected branches – allowed to push. Adjusted to: developers + masters. as shown in Figure 4
5. Push again, report an error: error: failed to push some refs to. as shown in Figure 5
6. Check the commit record and reset to the latest version before the merge of the master branch. as shown in Figure 6
7. Repository settings – protected branches. Delete the branch master and click the button unprotect. as shown in Figure 7
8. Push again, the push is successful. Restore the operations done in Step 7 and Step 4. as shown in Figure 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) Success (2921 ms @ 2020/06/29 16:42:52)







