この記事ではgit push時に以下のエラーYou are not allowed to push code to protected branches on this projectが発生した場合の対処方法をメモしておきます。
git push時に「Everything up-to-date」と表示されて困っている方は以下の記事を参考にしてください。
それでは解説していきます。
問題
git pushしたとき、以下のような結果になりました。
XXXXX@DESKTOP-AQBVPOG MINGW64 /c/workspace/prj1 (master)
$ git push -u origin master
Counting objects: 3, done.
Writing objects: 100% (3/3), 285 bytes | 285.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0)
remote: GitLab: You are not allowed to push code to protected branches on this project.
To http://localhost:8888/group1/prj1.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'http://localhost:8888/group1/prj1.git'
このエラーが出たとき、私はGitLabのdeveloperユーザでmasterブランチへpushしようとしていました。
とりあえずGoogle翻訳にかけてみたところ、次のとおり翻訳されました。
あなたがこのプロジェクトに保護されたブランチにコードをプッシュすることはできません。
そして気づきました。developerユーザの場合、masterブランチへpush出来ないことを。
次の画像を見ると、masterブランチがprotectedになっていることを確認できました。

対処方法
protectedが付いているブランチへはgit pushすることができません。
なので、一旦別ブランチへpushしたあと、マージリクエストを作成すればOKです。
以上。
頭脳一式 ![【GitLab】git cloneできないときの対処方法。[Failed to connect to localhost port 80_ Connection refused]が発生した場合](https://i0.wp.com/www.zunouissiki.com/wp-content/uploads/2018/12/%E3%80%90GitLab%E3%80%91git-clone%E3%81%A7%E3%81%8D%E3%81%AA%E3%81%84%E3%81%A8%E3%81%8D%E3%81%AE%E5%AF%BE%E5%87%A6%E6%96%B9%E6%B3%95%E3%80%82Failed-to-connect-to-localhost-port-80_-Connection-refused%E3%81%8C%E7%99%BA%E7%94%9F%E3%81%97%E3%81%9F%E5%A0%B4%E5%90%88.png?resize=160%2C160&ssl=1)
