How do I avoid developers from create branches that doesn't follow one of the patterns below?
user-story/W-*
bugfix/W-*
How do I avoid developers from create branches that doesn't follow one of the patterns below?
user-story/W-*
bugfix/W-*
GitHub has branch protection rules which can restrict certain branches, but it doesn't have negative patterns, so there's no way to prevent all patterns but given ones.
Depending on your goal, you can implement a couple of approaches:
I will point out that your proposed policy has the downside that if someone is working on something experimental that doesn't fit into a bug fix or user story, then blocking the creation of those branches altogether (if it were possible) would prevent users from pushing that data to the remote. I've often ended up doing this and at times this work has ended up being really useful, potentially as a base for future work.