Alon Shlider
Alon Shlider

Reputation: 1298

Creating a pull request rule on GitHub that prevents me to accidentally push new code to main branch

I am working on a repo where I am the owner and only author in it.

I want to have in my repo the same behavior as I would when working with a team that protects my branch from direct commits as they must go through a Pull Request. The reason for doing so is to protect from my own mistakes as I sometimes go back to main branch and accidentally push code to it. I want only code that passed through a Pull Request to be able to be merged to main branch.

In order to achieve such behavior I added the following rule to my main branch -

enter image description here

Which is almost what I need, expect that I am locked without the ability to approve my PR's as there is a message I get saying authors of the PR can't approve their PR's - a logical error nonetheless, but if I am working alone in the repo this is not what I am looking for.

How can I achieve what I am looking for?

Upvotes: 0

Views: 714

Answers (1)

knittl
knittl

Reputation: 265211

Simply disable "Require approvals" (the second checkbox in your screenshot), you will still be required to create a PR.

You can merge your own PRs, the only thing you cannot do is to approve your own work (after all: why would you? Hopefully you deem your own changes good!)

Upvotes: 1

Related Questions