Branch Protection on multiple branches

Can’t you do this with simply * ? 

I’m looking for somethign that would let me do master OR development. Seems like such a common thing, kind of interesting that was overlooked.

2 Likes

Wanted to weign in myself here. Something like {master, develop} would make my life much easier as I help to manage about 28 repositories!

8 Likes

* worked for me in order to apply protection rule over all of existing branches

Any update on this? At least update the documentation that says github does not use fnmatch syntax. Reading the documentation, we would fully expect to use fnmatch like {master,develop} to match two branches.

https://help.github.com/en/github/administering-a-repository/configuring-protected-branches

8 Likes

So the solution that I figure out was to use

[development]*[master]*

It will look for a branch named “development” 0 or more times and the same for “master”.

6 Likes

Greenshot 2020-04-03 18.00.15.png

My mistake was not using * at the end to match branches such as v1-ssr-mst-aptd-gcms-lcz-sty.

It matters, the rule isn’t just a prefix.

This works for me:

[development,master]*
3 Likes

I’m not sure how you got this to work, but it doens’t work for me. It appears to match all the characters in the string, so any branch with an “d” in it becomes a match. I.e, development, dev-randomfeature, dev-anything

@dnorton29 wrote:

So the solution that I figure out was to use

[development][master]

It will look for a branch named “development” 0 or more times and the same for “master”.

1 Like

In our repo we have multiple release branches: the master branch as the next branch and multiple LTS branches with the naming pattern major.minor.x like 1.3.x. We would like to enable the same protection for the master and every LTS branch. Right now we can do this only using two separate rules one with the master and the other with the *.*.x pattern. It would be great if we can provide these in one pattern, so we can manage the branch protection rules for our release branches without duplicating anything.

Been trying for hours, not a single pattern did work.
And yes, it works on other fnmatch implementations. The least you guys can you is update the documentation :confused:

1 Like

[main,master]* is working for me, but I don’t know why.

Whatever is decided as a pattern, could we agree that a info note should be attached to the field in some way? It is obvious that the allowed pattern syntax is NOT obvious and non-trivial.

Why not attach some link, or some explanatory text for when I try to use it again in a few months? It’s rather punitive to intermittent users to omit any tool-tip text at all from the UI.

The suggested [development,master]* doesn’t yield the correct result here:

image

It could be people who have success with this may have had just as much success with *.

That doesn’t work because [abc] defines a character class, not alternatives. So that rule matches any branch that starts with any of the characters within the brackets, followed by whatever.