What are Protected Branches?
It’s a feature in GitHub where a branch has to comply with certain rules before any actions can take place in that branch. Some common examples include:
Prevent Direct Pushes
Disallow users from directly pushing changes to the branch. Instead, changes must be made through pull requests (PRs) which can be reviewed and approved by other team members.
Require Pull Request Reviews
Enforce that all changes must be made through PRs and require a certain number of approvals from designated reviewers before merging.
Require Status Checks to Pass Before Merging
Ensure that all required CI/CD checks (like tests, code quality checks, etc.) pass before a PR can be merged. This helps maintain code quality and stability.
Require Linear History
Enforce a linear commit history by preventing merge commits and requiring rebasing. This keeps the commit history clean and easy to follow.
Prevent Force Pushes and Deletions
Disallow force pushes to the branch, which can overwrite commits, and prevent the branch from being deleted accidentally or maliciously.