You are configuring a repository's branch protection rule for the main branch. You want to ensure that every merged commit history remains linear (no merge commits). Which branch protection setting should you enable?
- A. Require signed commits
- B. Restrict who can push to matching branches
- C. Require a pull request before merging
- D. Require linear history✓ Correct
Explanation
'Require linear history' prevents merge commits from being pushed to the protected branch, forcing contributors to use squash merges or rebase merges instead, which keeps the commit history linear.
Why the others are wrong:
- 'Require a pull request before merging' enforces code review workflow but does not prevent merge commits.
- 'Require signed commits' enforces GPG/SSH commit signing for auditability but has nothing to do with history linearity.
- 'Restrict who can push' controls who has write access but does not affect merge strategy or history shape.