1
0
mirror of synced 2026-01-22 09:02:55 -05:00

Merge pull request #27506 from github/davidstaheli/restrict-create-branch

Branch protection rule: allow restricting creation of matching branches
This commit is contained in:
Jenni Christensen
2022-05-10 11:03:42 -07:00
committed by GitHub
6 changed files with 18 additions and 5 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 22 KiB

View File

@@ -161,9 +161,13 @@ By default, protected branch rules do not apply to people with admin permissions
You can enable branch restrictions if your repository is owned by an organization using {% data variables.product.prodname_team %} or {% data variables.product.prodname_ghe_cloud %}.
{% endif %}
When you enable branch restrictions, only users, teams, or apps that have been given permission can push to the protected branch. You can view and edit the users, teams, or apps with push access to a protected branch in the protected branch's settings. When status checks are required, the people, teams, and apps that have permission to push to a protected branch will still be prevented from merging if the required checks fail. People, teams, and apps that have permission to push to a protected branch will still need to create a pull request when pull requests are required.
When you enable branch restrictions, only users, teams, or apps that have been given permission can push to the protected branch. You can view and edit the users, teams, or apps with push access to a protected branch in the protected branch's settings. When status checks are required, the people, teams, and apps that have permission to push to a protected branch will still be prevented from merging into the branch when the required checks fail. People, teams, and apps that have permission to push to a protected branch will still need to create a pull request when pull requests are required.
You can only give push access to a protected branch to users, teams, or installed {% data variables.product.prodname_github_apps %} with write access to a repository. People and apps with admin permissions to a repository are always able to push to a protected branch.
{% if restrict-pushes-create-branch %}
Optionally, you can apply the same restrictions to the creation of branches that match the rule. For example, if you create a rule that only allows a certain team to push to any branches that contain the word `release`, only members of that team would be able to create a new branch that contains the word `release`.
{% endif %}
You can only give push access to a protected branch, or give permission to create a matching branch, to users, teams, or installed {% data variables.product.prodname_github_apps %} with write access to a repository. People and apps with admin permissions to a repository are always able to push to a protected branch or create a matching branch.
### Allow force pushes

View File

@@ -105,9 +105,11 @@ When you create a branch rule, the branch you specify doesn't have to exist yet
![Apply the rules above to administrators checkbox](/assets/images/help/repository/include-admins-protected-branches.png)
1. Optionally,{% ifversion fpt or ghec %} if your repository is owned by an organization using {% data variables.product.prodname_team %} or {% data variables.product.prodname_ghe_cloud %},{% endif %} enable branch restrictions.
- Select **Restrict who can push to matching branches**.
![Branch restriction checkbox](/assets/images/help/repository/restrict-branch.png)
- Search for and select the people, teams, or apps who will have permission to push to the protected branch.
![Branch restriction search](/assets/images/help/repository/restrict-branch-search.png)
![Branch restriction checkbox](/assets/images/help/repository/restrict-branch.png){% if restrict-pushes-create-branch %}
- Optionally, to also restrict the creation of matching branches, select **Restrict pushes that create matching branches**.
![Branch creation restriction checkbox](/assets/images/help/repository/restrict-branch-create.png){% endif %}
- Search for and select the people, teams, or apps who will have permission to push to the protected branch or create a matching branch.
![Branch restriction search]{% if restrict-pushes-create-branch %}(/assets/images/help/repository/restrict-branch-search-with-create.png){% else %}(/assets/images/help/repository/restrict-branch-search.png){% endif %}
1. Optionally, under "Rules applied to everyone including administrators", select **Allow force pushes**.
![Allow force pushes option](/assets/images/help/repository/allow-force-pushes.png)
{% ifversion fpt or ghec or ghes > 3.3 or ghae-issue-5624 %}

View File

@@ -0,0 +1,7 @@
# Issue 6045
# Restrict pushes that create matching branches option, within branch restrictions
versions:
fpt: '*'
ghec: '*'
ghes: '>=3.6'
ghae: 'issue-6045'