Protected branches ensure that collaborators on your repository cannot make irrevocable changes to branches. These branches can also be protected by requiring pull requests to have at least one approved review before they can be merged.
If you own a repository with multiple collaborators who create branches and open pull requests, you may need to enforce branch protections to keep your project and pull requests organized and safe. For more information, see "Configuring protected branches."
Protected branches block some features of Git on a branch that a repository administrator chooses to protect. A protected branch:
- Can't be force pushed
- Can't be deleted
Optionally, a protected branch also:
- Can't have changes merged into it until required status checks pass. For more information, see "About required status checks."
- Can't have changes merged into it until required reviews are approved. For more information, see "Approving a pull request with required reviews."
- Can't be edited or have files uploaded to it from the web
If your repository belongs to an organization, you can restrict users or teams from pushing to a protected branch. For more information, see "About branch restrictions."