Protect branch in Github results in "Rule is invalid"

Viewed 2714

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

2 Answers

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.

For anyone still struggling with this. Make sure there is no space in your rule name.

ie:

"Protect Main" -> error

"ProtectMain" -> fine.

Related