About converting branch protections to rulesets
Rulesets give you clearer visibility and control over how protections apply to a repository. Unlike branch protection rules, multiple rulesets can apply to the same branch at the same time, and people with read access can view the active rulesets. This helps developers understand the rules that affect them and lets auditors review repository protections without administrator access.
To move your existing protections to this model, convert one branch protection rule at a time in a guided flow. GitHub generates one or more rulesets that preserve the original rule's behavior. You can preview the rulesets and verify the result before you remove the original branch protection rule.
For more information about rulesets, see ルールセットについて.
Converting a branch protection rule to a ruleset
-
GitHub で、リポジトリのメイン ページに移動します。
-
リポジトリ名の下にある [Settings] をクリックします。 [設定] タブが表示されない場合は、 [] ドロップダウン メニューを選び、 [設定] をクリックします。
![タブを示すリポジトリ ヘッダーのスクリーンショット。 [設定] タブが濃いオレンジ色の枠線で強調表示されています。](/assets/cb-28260/images/help/repository/repo-actions-settings.png)
-
サイドバーの [Code and automation] セクションで、 [Branches] をクリックします。
-
Under "Branch protection rules", find the rule you want to convert, then click Convert to ruleset.
-
Set the ruleset name for each ruleset that will be created in this conversion.
-
Review the "New behavior" section to understand what will change when you create the ruleset or rulesets.
-
Optionally, to remove the original branch protection rule as part of the conversion, select Delete branch protection rule once migration is done.
-
Click Create ruleset. If the conversion produces more than one ruleset, the button includes the number of rulesets, for example, Create 2 rulesets.
If you keep the original branch protection rule, it continues to protect matching branches. An Active ruleset is enforced alongside it, so changes must satisfy both.
メモ
The conversion covers all branch protection types with the exception of the "Require conversation resolution before merging" setting. In branch protections, this setting exists on its own. In rulesets, conversation resolution is part of the pull request rule and only applies when that rule is enabled. As a result, this setting does not map one to one during conversion. See ルールセットで使用できるルール.
The new ruleset has an Active status, which means that it is enforced as soon as it is created.
Deleting the original branch protection rule
After you convert a rule, return to the Branches settings page. If you did not opt to delete the branch protection rule during the conversion process and the new ruleset fully covers it, the listed rule displays the message "This rule is fully covered by rulesets and can be safely deleted", and a Delete button appears in place of the Convert to ruleset button.
Before you delete the original rule, we recommend confirming that the new ruleset behaves as you expect. When you are ready, click Delete to remove the branch protection rule.