
main branch, enforce pull request reviews, and adopt a scalable workflow for collaborative development.
Current Workflow and Its Drawbacks
Most teams begin with a simple process:- Clone the central repo.
- Make changes directly on
main. - Push updates back to
main.
- Unreviewed code: Bugs or security flaws can reach production unvetted.
- Frequent merge conflicts: Multiple direct pushes to
mainoften collide.
Enabling Branch Protection Rules
Branch protection rules block direct pushes to critical branches (likemain) and enforce quality checks before merging.

Key Branch Protection Settings
| Rule | Description | Benefit |
|---|---|---|
| Require pull request reviews | Prevents direct commits to main | Ensures code is peer-reviewed |
| Enforce status checks | CI/CD pipelines must pass | Avoids broken or failing builds |
| Dismiss stale approvals | Forces fresh reviews after changes | Keeps feedback up to date |
Configure branch protection under Settings > Branches in your GitHub repository. For details, see GitHub Branch Protection.
- Direct pushes to
mainare blocked. - All changes must go through a pull request.
- Required CI/CD checks must be green before merging.
Recommended GitHub Workflow
Adopt a feature-branch workflow to scale collaboration:- Clone the repository locally.
- Create a new feature branch:
feature/your-feature-name. - Commit work to the feature branch.
- Push the branch and open a pull request against
main. - Request reviews and address feedback.
- Merge when approvals and checks are complete.

Avoid emergency fixes directly on
main. Even urgent patches should follow the pull request process to maintain auditability.What’s Next?
In the next article, we’ll demonstrate how to apply branch protection rules in the GitHub settings and manage pull requests step by step.