4
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Github デフォルト(main)ブランチ保護のための設定

4
Last updated at Posted at 2025-08-12

概要

Githubの特定のリポジトリを対象にデフォルト(main)ブランチ保護のため下記の設定を行う方法を簡単にまとめる。

  • force pushブロック
  • ブランチ削除ブロック
  • マージにはPRを強制、PRマージには最低1件のApproval必須

前提

設定を施すリポジトリの管理者権限を持っていること。

方法

  1. リポジトリのTOPにアクセス

  2. グロナビの「Settings」をクリック

  3. 左サイドバーで「Branches」をクリック

  4. 「Add branch ruleset」をクリック

  5. 下記のように各項目を設定して「Create」をクリック

    項目 内容
    Ruleset Name 任意(筆者はmain_push_blockとした)
    Enforcement status Active
    Bypass list 設定しない
    Target branches Include default branch
    ブランチ削除ブロック設定 「Restrict deletions」にチェック
    マージにはPRを強制、PRマージには最低1件のApproval必須 「Require a pull request before merging」にチェック
    Requried approvalsのプルダウンを1に設定
    force pushブロック 「Block force pushes」にチェック

※作成したルールはリポジトリのsettingsのサイドバーのRulesetsに表示される

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?