Check ID: repository_default_branch_requires_linear_history
Provider: GitHub
Service: repository
Severity: LOW
Categories: software-supply-chain
Resource type: NotDefined

What this check verifies

GitHub repository default branch enforces Require linear history, blocking merge commits and allowing only squash or rebase merges

Risk

Without a linear history, commit provenance is harder to verify, weakening integrity and accountability. Merge commits can obscure diffs entering the default branch, hindering audits and rollbacks, enabling unnoticed malicious or unreviewed code, and delaying incident response.

Recommendation

Enable Require linear history on the default branch and allow only squash or rebase merges. Reinforce with branch protection: require pull requests and reviews, status checks, and signed commits. Limit bypass to trusted roles (least privilege) to preserve traceability and defense in depth.

Remediation

curl -X PUT -H "Authorization: Bearer <TOKEN>" -H "Accept: application/vnd.github+json" -H "Content-Type: application/json" https://api.github.com/repos/<OWNER>/<REPO>/branches/<DEFAULT_BRANCH>/protection -d '{"required_status_checks":null,"enforce_admins":false,"required_pull_request_reviews":null,"restrictions":null,"required_linear_history":true}'

References

Where this check fires

This check runs on every scheduled scan against your GitHub account. Findings appear at Cloud Security → Findings filterable by Check ID = repository_default_branch_requires_linear_history. To re-evaluate after a fix, hit Run now on the account’s schedule under Cloud Security → Schedules — the next scan re-checks this control and marks the finding fixed or keeps it persistent.
← Back to GitHub checks