0
0

Github - mainなどのブランチへの強制 pushを禁止する設定 ( 組織のレポジトリ > 保護ルール )

Posted at

Githubでの設定

レポジトリのSettings -> Branches からルールを追加する

image

これだけで git での強制pushを禁止できるようだ

git のエラー例

$ git push --force-with-lease
 ! [remote rejected]     some-branch -> some-branch (protected branch hook declined)
error: failed to push some refs to 'https://github.com/xxx/yyy.git'

コミットを積んでのpushは禁止できるのか?

保護ブランチに対して、強制pushではなく、コミットを積んでのpushは禁止できるのか?

試したところ、

  • Require status checks to pass before merging
  • Lock Branch

を有効にしても、git push の時に WARNING 的なメッセージが表示されるだけで、Github にはしっかりとコミットが反映されてしまうようだった

git操作の例

git push
...
remote: Bypassed rule violations for refs/heads/some-branch:
remote:
remote: - Cannot change this locked branch
remote:
...

( 2024/09/17 現在 )

チャットメンバー募集

何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。

プロフィール・経歴

0
0
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
0
0