Skip to main content

Protecting branches in your enterprise with rulesets

Create rulesets at the enterprise level to enforce code governance policies across all repositories.

You can create rulesets to control how users can interact with code in repositories across your enterprise. You can:

  • Create a branch or tag ruleset to control things like who can push commits to a certain branch, how commits must be formatted, or who can delete or rename a tag.
  • Create a push ruleset to block pushes to a private or internal repository and the repository's entire fork network. Push rulesets allow you to block pushes based on file extensions, file path lengths, file and folder paths, and file sizes.

Using ruleset enforcement statuses

ルールセットの作成または編集中に、適用ステータスを使用してルールセットの適用方法を構成できます。

ルールセットには、次の適用ステータスのいずれかを選択できます。

  • Active: ルールセットは作成時に適用されます。
  • Evaluate: ルールセットは適用されませんが、[Rule Insights] ページでルールに違反するアクションと違反しないアクションを監視できます。
  • Disabled: ルールセットは、適用または評価されません。

「評価」モードを使用することは、ルールセットを適用せずにテストするための優れたオプションです。 「ルールの分析情報」ページを使用して、そのコントリビューションがルールに違反したかどうかを確認できます。 詳しくは、「リポジトリのルールセットの管理」をご覧ください。

Creating a branch or tag ruleset

  1. GitHub の右上隅にあるプロフィール画像をクリックします。

  2. ご自分の環境に応じて、[Your enterprise] または [Your enterprises] をクリックし、表示するエンタープライズをクリックします。

  3. ページの上部にある [ Policies] をクリックします。

  4. Under "Policies", click Code.

  5. 新しいルールセット」をクリックします。

  6. ブランチを対象とするルールセットを作成するには、 [新しいブランチ ルールセット] をクリックします。 または、タグを対象とするルールセットを作成するには、[新しいタグ ルールセット] をクリックします。

  7. [ルールセット名] に、ルールセットの名前を入力します。

  8. 必要に応じて、既定の適用状態を変更するには、 [Disabled] をクリックして、新しい適用状態を選びます。 適用ステータスの詳細については、「ルールセットについて」を参照してください。

For a more detailed explanation of the available options, see Enterprise でルールセットを使ってコード ガバナンスを適用する.

Next steps

Learn how to monitor and audit activity in your enterprise. See Using the audit log for your enterprise.