Protected branches ensure that collaborators on your repository cannot make irrevocable changes to branches. Enabling protected branches also allows you to enable other optional checks and requirements, like required status checks and required reviews.

Repository owners and people with admin permissions for a repository can enforce certain workflows or requirements, before a collaborator can merge a branch in your repository by configuring protected branch settings. For more information, see "Configuring protected branches."

Branch protection settings

When you enable branch protection for a specific branch, collaborators cannot force push to the protected branch or delete the branch by default. You can enable other branch protection settings, so that collaborators:

  • Can't merge changes into the protected branch unless required status checks pass. For more information, see "About required status checks."
  • Can't merge changes into the protected branch until required reviews are approved. For more information, see "Approving a pull request with required reviews."
  • Can't edit the protected branch or upload files to it from the web
  • Can't merge changes into the protected branch until changes to files that have a designated code owner have been approved by that owner. For more information, see "About codeowners."

If your repository is owned by an organization, you can restrict users or teams from pushing to a protected branch. For more information, see "About branch restrictions."

Further reading