Ensure linear history is enforced on the default branch
Framework Reference: A.8.25 (Secure Development Lifecycle) Integration: GitHub – Branch Protection
Why this matters
A linear commit history prevents merge commits on protected branches. It keeps history easy to follow and simplifies revert and forensic analysis. GitHub enforces this through the Require linear history branch protection setting, which forces squash or rebase merges into the protected branch.
What this check does
This check verifies that the default branch is covered by a branch protection rule with Require linear history enabled. GitHub requires that squash or rebase merging be allowed in the repository before you can enable this setting.
How to fix it
From the GitHub web console
Open the repository.
- Go to Settings → Branches.
- Under Branch protection rules, click Add rule or edit the rule for the default branch (for example,
main
). - Enable Require linear history.
- Save the rule. GitHub Docs+1
Note: Squash merge or rebase merge must be allowed in the repository to enable linear history.
Exceptions
- The rule applies only to branches targeted by the protection rule.
- Admins can bypass protections unless you also enforce protections for administrators.