Search code examples
githubbranch

Protect branch in Github results in "Rule is invalid"


I'm trying to create a simple rule to protect the main branch of a repository but it results in Rule is invalid. I am the creator of the repo. Using GitHub Enterprise Server 2.22.6.

What am I missing?

Steps:

  1. Settings
  2. Branches
  3. New Rule
  4. Name the rule Enter branch name to protect (answer)
  5. Select Require pull request review before merging

enter image description here

  1. Create

Error: Rule is invalid

enter image description here


Solution

  • The Branch name pattern dialog box is meant to contain the name of a branch or a regular expression to capture multiple branch names. It is not meant to contain the name or description of a branch protection rule.

    Try entering a regular expression or the name of the branch you'd like to protect (e.g. main instead of Protect Master) into the Branch name pattern textbox.

    See the docs here for more information.