Branch Protection
Branch protection is a crucial feature used to safeguard your core or critical branches for security and quality control purposes. These rules help maintain code integrity by enforcing specific workflows and review processes.
Accessing Branch Protection Settings
To configure branch protection:
- Navigate to your API repository
- Select the Settings tab
- Go to the Branches sub-tab
- View existing protection policies or create new ones
Creating Protection Rules
Click the Add Rule button to create a new branch protection policy. Each policy allows you to specify:
Branch Selection
- Define which branches to protect using pattern-based branch names (e.g.,
main
,release/*
) - Apply rules to single branches or groups of branches using wildcards
Protection Methods
- Disable direct pushes to protected branches
- Create whitelists for users/roles who can bypass protection
- Enforce code review workflow
Pull Request Requirements
- Make pull requests mandatory for changes
- Specify the number of required approvals before merging
- Define who can approve pull requests
- Set other approval criteria
Merge Strategies
- Configure how pull requests can be merged (squash, rebase, merge commit)
- Set additional merge requirements
With properly configured branch protection rules, you can ensure that your critical branches maintain code quality and follow your team’s established development workflows.
Last updated on