Skip to main content

Управление наборами правил для репозитория

Вы можете изменять, отслеживать и удалять существующие наборы правил в репозитории, чтобы изменить способ взаимодействия людей с определенными ветвями и тегами.

Кто эту функцию можно использовать?

Любой пользователь с доступом на чтение к репозиторию может просматривать наборы правил репозитория. Люди с доступом администратора к репозиторию, или настраиваемая роль с разрешением "Изменить правила репозитория", может создавать, изменять и удалять наборы правил для репозитория.

Наборы правил доступны в общедоступных репозиториях с GitHub Free и GitHub Free для организаций, а также в общедоступных и частных репозиториях с GitHub Pro, GitHub Teamи GitHub Enterprise Cloud. Дополнительные сведения см. в разделе "Планы GitHub".

Наборы правил push-уведомлений доступны для плана GitHub Team во внутренних и частных репозиториях и вилки репозиториев с включенными наборами правил push-уведомлений.

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 temporarily disable a ruleset to troubleshoot any unintended 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."

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.

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.

  1. On GitHub.com, navigate to the main page of the repository.

  2. 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.

    Screenshot of the file tree view for a repository. A dropdown menu for branches is expanded and outlined in dark orange.

  3. To the left of the branch name, click .

  4. Optionally, to filter the results click the tabs or use the "Search branches" search bar.

  5. Click the name of the ruleset you want to view.

Editing a ruleset

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.

  1. On GitHub.com, navigate to the main page of the repository.

  2. Under your repository name, click Settings. If you cannot see the "Settings" tab, select the dropdown menu, then click Settings.

    Screenshot of a repository header showing the tabs. The "Settings" tab is highlighted by a dark orange outline.

  3. In the left sidebar, under "Code and automation," click Rules, then click Rulesets.

    Screenshot of the sidebar of the "Settings" page for a repository. The "Rules" sub-menu is expanded, and the "Rulesets" option is outlined in orange.

  4. On the "Rulesets" page, click the name of the ruleset you want to edit.

  5. Change the ruleset as required. For information on the available rules, see "Available rules for rulesets."

  6. 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."

  1. On GitHub.com, navigate to the main page of the repository.

  2. Under your repository name, click Settings. If you cannot see the "Settings" tab, select the dropdown menu, then click Settings.

    Screenshot of a repository header showing the tabs. The "Settings" tab is highlighted by a dark orange outline.

  3. In the left sidebar, under "Code and automation," click Rules, then click Rulesets.

    Screenshot of the sidebar of the "Settings" page for a repository. The "Rules" sub-menu is expanded, and the "Rulesets" option is outlined in orange.

  4. Click the name of the ruleset you want to delete.

  5. To the right of the ruleset's name, select , then click Delete ruleset.

    Screenshot of the page for editing a ruleset. Below a button labeled with three dots, an option labeled "Delete ruleset" is outlined in orange.