How to protect master branch on solo-developer projects?

This is a common problem I have in several repos: I would like to protect the master branch on the projects I work on, so that I know every change has to have been built/tested by GitHub actions.

The problem is that since I am the only developer, I cannot get any PRs approved since you can’t approve your own PR. This means I have to enable “Allow administrator override”, which means I could still accidentally push to the master branch.

Is there any way to ensure that I, even as an administrator, cannot push directly to the master branch, and have to have a PR build successfully, but can still merge PRs without having a second developer for approval?

Hi @matt-winfield, welcome to the GitHub Support Community!

I think you could set this up by enabling “Require status checks to pass” but not enabling “require pull request reviews”

You can then enable “Include administrators” to require these restrictions on yourself

That should mean that you’re not blocked from merging pull requests without a review, but you’ll still be blocked if your checks or CI hasn’t finished running.

1 Like