diff --git a/assets/images/help/repository/restrict-branch-create.png b/assets/images/help/repository/restrict-branch-create.png new file mode 100644 index 0000000000..04d35981f6 Binary files /dev/null and b/assets/images/help/repository/restrict-branch-create.png differ diff --git a/assets/images/help/repository/restrict-branch-search-with-create.png b/assets/images/help/repository/restrict-branch-search-with-create.png new file mode 100644 index 0000000000..8231ce8989 Binary files /dev/null and b/assets/images/help/repository/restrict-branch-search-with-create.png differ diff --git a/assets/images/help/repository/restrict-branch-search.png b/assets/images/help/repository/restrict-branch-search.png index 43057379d4..2b50b88e52 100644 Binary files a/assets/images/help/repository/restrict-branch-search.png and b/assets/images/help/repository/restrict-branch-search.png differ diff --git a/content/repositories/configuring-branches-and-merges-in-your-repository/defining-the-mergeability-of-pull-requests/about-protected-branches.md b/content/repositories/configuring-branches-and-merges-in-your-repository/defining-the-mergeability-of-pull-requests/about-protected-branches.md index 251a1f2449..ec692ec89a 100644 --- a/content/repositories/configuring-branches-and-merges-in-your-repository/defining-the-mergeability-of-pull-requests/about-protected-branches.md +++ b/content/repositories/configuring-branches-and-merges-in-your-repository/defining-the-mergeability-of-pull-requests/about-protected-branches.md @@ -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 diff --git a/content/repositories/configuring-branches-and-merges-in-your-repository/defining-the-mergeability-of-pull-requests/managing-a-branch-protection-rule.md b/content/repositories/configuring-branches-and-merges-in-your-repository/defining-the-mergeability-of-pull-requests/managing-a-branch-protection-rule.md index 3a6acd3c4a..249403b393 100644 --- a/content/repositories/configuring-branches-and-merges-in-your-repository/defining-the-mergeability-of-pull-requests/managing-a-branch-protection-rule.md +++ b/content/repositories/configuring-branches-and-merges-in-your-repository/defining-the-mergeability-of-pull-requests/managing-a-branch-protection-rule.md @@ -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 %} diff --git a/data/features/restrict-pushes-create-branch.yml b/data/features/restrict-pushes-create-branch.yml new file mode 100644 index 0000000000..156a3b6018 --- /dev/null +++ b/data/features/restrict-pushes-create-branch.yml @@ -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'