After creating a ruleset, you can still make changes to it. For example, you can add rules to better protect your branches or tags, or you can switch your ruleset from "Evaluate" mode to "Active" after testing its effects on the contributor experience for your repository.
You can use the REST and GraphQL APIs to manage rulesets. For more information, see "REST API endpoints for rules" and "Mutations."
Tip: If you're the owner of an organization, you can create rulesets at the organization level. You can apply these rulesets to specific repositories in your organization, and to specific branches in those repositories. For more information, see "Creating rulesets for repositories in your organization."
Viewing rulesets for a repository
On the "Rulesets" page, anyone with read access to the repository can view the active rulesets targeting a certain branch, tag, or push restriction. You will also see rulesets running in "Evaluate" mode, which are not enforced.
For push rulesets for forked repositories, the "Rulesets" page will indicate that the ruleset is managed by the source repository where the rule is applied.
-
On GitHub, navigate to the main page of the repository.
-
From the file tree view on the left, select the branch dropdown menu, then click View all branches. You can also find the branch dropdown menu at the top of the integrated file editor.
-
To the left of the branch name, click .
-
Optionally, to filter the results click the tabs or use the "Search branches" search bar.
-
Click the name of the ruleset you want to view.
Editing a ruleset
Note: If a ruleset was created at the organization level, you cannot edit the ruleset from the repository's settings. If you have permission to edit the ruleset, you can do so in your organization's settings. For more information, see "Managing rulesets for repositories in your organization."
You can edit a ruleset to change parts of the ruleset, such as the name, bypass permissions, or rules. You can also edit a ruleset to change its status, such as if you want to enable or temporarily disable a ruleset.
-
On GitHub, navigate to the main page of the repository.
-
Under your repository name, click Settings. If you cannot see the "Settings" tab, select the dropdown menu, then click Settings.
-
In the left sidebar, under "Code and automation," click Rules, then click Rulesets.
-
On the "Rulesets" page, click the name of the ruleset you want to edit.
-
Change the ruleset as required. For information on the available rules, see "Available rules for rulesets."
-
At the bottom of the page, click Save changes.
Deleting a ruleset
Tip: If you want to temporarily disable a ruleset but do not want to delete it, you can set the ruleset's status to "Disabled." For more information, see "Editing a ruleset."
-
On GitHub, navigate to the main page of the repository.
-
Under your repository name, click Settings. If you cannot see the "Settings" tab, select the dropdown menu, then click Settings.
-
In the left sidebar, under "Code and automation," click Rules, then click Rulesets.
-
Click the name of the ruleset you want to delete.
-
To the right of the ruleset's name, select , then click Delete ruleset.
Using ruleset history
Notes:
- Ruleset history is currently in public preview and subject to change.
- Only changes made to a ruleset after the public preview release, on October 11, 2023, are included in the ruleset history.
You can view all the changes to a ruleset and revert back to a specific iteration. You can also download a JSON file containing the ruleset's configuration at a specific iteration. The bypass list of a ruleset is excluded from the exported JSON file.
-
On GitHub, navigate to the main page of the repository.
-
Under your repository name, click Settings. If you cannot see the "Settings" tab, select the dropdown menu, then click Settings.
-
In the left sidebar, under "Code and automation," click Rules, then click Rulesets.
-
To view the history of changes to the ruleset, select to the right of the ruleset's name, then click History.
-
To the right of the specific iteration, select , then click Compare changes, Restore, or Download.
Importing a ruleset
You can import a ruleset from another repository or organization using a JSON file. This can be useful if you want to apply the same ruleset to multiple repositories or organizations.
-
On GitHub, navigate to the main page of the repository.
-
Under your repository name, click Settings. If you cannot see the "Settings" tab, select the dropdown menu, then click Settings.
-
In the left sidebar, under "Code and automation," click Rules, then click Rulesets.
-
Select the New ruleset dropdown, then click Import a ruleset.
-
Open the exported JSON file.
-
Review the imported ruleset and click Create.
Viewing insights for rulesets
You can view insights for rulesets to see how rulesets are affecting a repository. On the "Rule Insights" page, you will see a timeline of the following user actions. You can use filters to find what you're looking for.
- Actions that have been checked against one or more rulesets and passed.
- Actions that have been checked against one or more rulesets and failed.
- Actions where someone has bypassed one or more rulesets.
If a ruleset is running in "Evaluate" mode, you can see actions that would have passed or failed if the ruleset had been active.
-
On GitHub, navigate to the main page of the repository.
-
Under your repository name, click Settings. If you cannot see the "Settings" tab, select the dropdown menu, then click Settings.
-
In the left sidebar, under "Code and automation," click Rules, then click Insights.
-
On the "Rule Insights" page, use the dropdown menus at the top of the page to filter the actions by ruleset, branch, actor, and time period.
-
To see which specific rules failed or required a bypass, click , then expand the name of the ruleset.
-
Optionally, review merge queue details for corresponding pull requests in the same merge group.
Managing requests to bypass push rules
Note
Delegated bypass for push rules is currently in public preview and subject to change.
You can view and manage all requests for bypass privileges on the “Bypass Requests" page, located under the Rules settings of the repository.
-
On GitHub, navigate to the main page of the repository.
-
Under your repository name, click Settings. If you cannot see the "Settings" tab, select the dropdown menu, then click Settings.
-
Click Bypass Requests.
You can filter requests by approver (member of the bypass list), requester (contributor making the request), timeframe, and status. The following statuses are assigned to a request:
Status | Description |
---|---|
Cancelled | The request has been cancelled by the contributor. |
Completed | The request has been approved and the commit(s) have been pushed to the repository. |
Denied | The request has been reviewed and denied. |
Expired | The request has expired. Requests are valid for 7 days. |
Open | The request has either not yet been reviewed, or has been approved but the commit(s) have not been pushed to the repository. |
When a contributor requests bypass privileges to push a commit containing restricted content, members of the bypass list all receive an email notification containing a link to the request. Members of the bypass list then have 7 days to review and either approve or deny the request before the request expires.
The contributor is notified of the decision by email and must take the required action. If the request is approved, the contributor can push the commit containing the restricted content to the repository. If the request is denied, the contributor must remove the restricted content from the commit in order to successfully push the commit to the repository.