3

I need to make a branch protected directly when creating it. I know that I need to go to Settings and set it as protected from there, but what I'm looking for is to set the branch as protected automatically without the need to do that.

1

GitHub doesn't have a way to natively enable branch protection for new branches. However, you could set up an automated process using "Update branch protection" from the GitHub API to add branch protection to all new branches.

PUT /repos/:owner/:repo/branches/:branch/protection

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.