you are not allowed to push code to protected branches on this project(轉)


            、git

                                                     圖 1-1github

 

       報錯:failed to push some refs to 'http://*******.git'。ide

       一痛瞎踅摸以後,遠程控制電腦,在H電腦上,從新創建了一個test項目,以後走正常流程:gitlab

echo "# 123" >> README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin git@github.com:¥%…&&*@/123.git
git push -u origin master

 


       push成功沒有問題,說明GitLab庫級別配置,以及本地GitBash客戶端沒有問題。因而從新按照這個流程,本地新建文件夾,從新操做。ui


       操做結果同上圖1-1所示,失敗了。this

 

       分析:spa

       1.git clone下來沒有問題,commit本地倉庫沒有問題,就是推不上去,初步懷疑這個項目的配置有問題(讀寫權限不一致)。.net

       2.委託H同窗詢問其餘同事能不能clone下他們的項目,而後提交上去,等待驗證結果中。。。。。。code

 

       驗證:blog

       查看錯誤信息時候,發現醬紫的一句提示:「You are not allowed to push code to protected branches on this project.」 ,發現了嗎?這個項目的branch類型是「protected branches」!!!

       緊接着,開始逛StackOverFlow,please pay attention:尋找問題的時候,最好的站點是StackOverflow!!!,效率最高的也是StackOverflow。Besides, attach the link:https://stackoverflow.com/questions/32246503/how-to-fix-you-are-not-allowed-to-push-code-to-protected-branches-on-this-proje 。

      睜大眼睛:

      there's no problem - everything works as expected.
      In GitLab some branches can be protected. By default only 'master' user can commit to protected branches. master branch is protected by default - it forces developers to issue merge requests to be validated by project master before integrating them into main code.
      You can turn on and off protection on selected branches in Project Settings (where exactly depends on GitLab version - see instructions below).
      On the same settings page you can also allow developers to push into the protected branches. With this setting on, protection will be limited to rejecting operations requiring git push --force (rebase etc.)

       結合本文第一行的提示,公司新裝的gitlab。GitLab一些分支默認被保護,僅僅擁有master級別的用戶才能提交到保護分支,並且master分支默認是保護分支,其餘用戶須要經過合併issue請求來提交上去,靠!找到了。

      Since GitLab 9.0
      Project: "Settings" -> "Repository" -> scroll down to "Protected branches".
      Now you can select who is allowed to merge or push into selected branches (for example: you can turn off pushes to master at all, forcing all changes to branch to be made via Merge Requests). Or you can click "Unprotect" to completely remove protection from branch.

      如圖:

      (1)

     
                                                             

         (2)

               

                                       

      總結:

       1.定位問題是權限問題以後,就該把問題上報了,並且解決方案一併交給組長,是否是有很爽的感受。

相關文章
相關標籤/搜索