Now, admins can block creation of branches that match a configured name pattern. For example, if a repository's default branch is renamed from
main, admins can prevent any subsequent creation or push of the
master branch so that only the new branch name is used.
Previously, admins could use branch protection rules to restrict who could push to existing branches, but they couldn't block the creation of those branches. This is now possible using a branch protection setting named Restrict pushes that create matching branches. To use the setting, create a new branch protection rule with a name pattern that matches the branch name you want to block (e.g.
not-allowed*). Then, enable the settings Restrict who can push to matching branches and Restrict pushes that create matching branches, as shown here:
For more information, visit About protected branches in the GitHub documentation.
We appreciate feedback on this and other topics in GitHub's public feedback discussions.