版本:gitlab10.2.2
一旦设置master分支被保护,除了管理员之外的任何用户都无法直接向master提交代码,只要提交代码就会报错
# git push -u origin master
Total 0 (delta 0), reused 0 (delta 0)
remote: GitLab: You are not allowed to push code to protected branches on this project.
To git@192.168.1.12:develpment/myproject-test.git! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'git@192.168.1.12:develpment/myproject-test.git'
(1) 点击你的项目
(2) 点击【版本库】——【分支】
(3) 管理受保护的分支
(4) 点击展开
(5) 选择保护master分支
(6) 可以看到master分支已经被保护起来了