Bootstrap FreeKB - GitHub Actions - Prevent Commit to default main branch via a Ruleset
GitHub Actions - Prevent Commit to default main branch via a Ruleset

Updated:   |  GitHub Actions articles

Let's say you want to disable commits to the main branch of one of your GitHub repos. Fortunately, this is very easy to configure.

Then let's go to the repository Settings > Rules > Rulesets and let's create a rule set. In the Ruleset  checkmark Require a pull request before merging. That's all there really is to it.

 

You probably want to apply this ruleset to only the main/master/default branch.

 

 

 

 

Now, if you attempt to commit to the main branch, you'll see a message like this.

 

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter e27991 in the box below so that we can be sure you are a human.