問題:使用Git時,會碰到須要對某個分支進行保護,避免其餘人隨意push。git
這裏以gitlab爲例,具體操做以下:gitlab
1.進入項目blog
2.點擊左側列表中的Settingsit
3.點擊Protected Branchesast
4.進入後可發現,當前默認master分支爲受保護,即只能master角色能夠pushim
5.以develop分支爲例進行保護developer
如上圖區域1中,在Branch中選擇分支develop,點擊Protect,若是須要developer角色能夠push,則勾選「Developer can push」,點擊Protect以後,便可添加成功項目
6.幾個操做說明,上圖區域2img
①默認master分支受保護,且只有master角色能夠pushco
②已經添加好受保護的分支,也有Developers can push選項 表示:角色developer能夠push當前項目
③Unprotect 表示:不保護當前分支。點擊以後,當前分支再也不受保護,developer和master都可push