1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Gitlabでmasterにプッシュできない

Posted at

経緯

外注先からの成果物をgitlabにアップロードしてもらうために、ユーザを作ってdeveloper権限振って、プッシュしてもらおうと思ったら、下記のエラーが発生したとの連絡が

! [remote rejected] master -> master (pre-receive hook declined)

結論

どうやらgitlabでは、developer権限者のmasterブランチへのpushをデフォルトで禁止しているようでした
この設定は設定のプロテクトから変更することができるのですが、ファーストプッシュ前ではレポジトリが作成されていないため、設定が存在しないため、変更することができない(デフォルトの設定が適用される)

解決策①:Maintainer権限を付与する

これが一番手っ取り早くてかんたんです
私はこの方法でやりました(めんどくさかったので。。。)

解決策②:正攻法?

  1. 作成者(Owner権限を持っているユーザー)がREADME.mdをコミットしてリポジトリとmasterブランチを作成する
  2. プロテクトを外すorDeveloperに権限付与(Setting→Repository→Protected BranchesをExpand)

SnapCrab_NoName_2021-2-24_20-54-15_No-00.png

解決策③:masterを使わない

developブランチなどを作成してそちらにプッシュしてもらう
masterへのマージは管理者で行う

これがあるべき姿な気はします
今回は小規模なプロジェクトだったので省きました

ちなみにこの方法でも②-1の手順を踏み、masterブランチを作成する必要があります

まとめ

上記を調べると、「プロテクト外せばいいよー」ってでてきたんだけと、「プロテクトなんてないじゃん。。。」てなって手詰まったので備忘録として残しておきます

1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?