Enhance your understanding of branch protection rules within version control workflows. This quiz covers core settings, permissions, and behaviors to help you configure repositories securely and efficiently.
Which branch protection rule prevents merging pull requests unless all required status checks pass, for example, ensuring that automated tests have succeeded?
Explanation: Required status checks ensure that specific checks (like automated tests) must complete successfully before merging. Enforce admin checks applies branch rules to administrators but does not enforce status checks themselves. Linear history enforcement mandates no merge commits, unrelated to test requirements. Signed commits required only insists on verified signatures. Only required status checks directly enforce passing checks before merges.
What branch protection setting should you enable to prevent force pushes that could overwrite commit history on a protected branch?
Explanation: Disallow force pushes ensures that no one can force-push changes, which could overwrite commit history. Restrict push access limits who can push, but not specifically force pushes. Require pull request reviews focuses on code review, not push permissions. Allow deletions is unrelated as it controls branch deletion. Disallow force pushes is the correct protection for commit history.
If you want all changes to a protected branch to be approved by at least one reviewer before merging, which rule should you configure?
Explanation: Require pull request reviews forces code changes to be approved by designated reviewers before merging. Require signed commits only verifies commit signatures, not reviews. Enforce linear merges restricts merge styles, not approvals. Allow force-push is the opposite of what you want, as it can bypass approvals. Thus, requiring pull request reviews is the correct rule for approvals.
How does enabling 'Include administrators' in branch protection rules affect repository admins with respect to those rules?
Explanation: Selecting 'Include administrators' ensures admins cannot bypass branch protection rules and must comply like other users. Admins are not entirely blocked from pushing; they just have no special bypass privileges. Without this setting, admins could ignore protection rules. Only receiving email notifications does not impact branch protection. The setting makes rules equally strict for everyone.
Which configuration allows deletion of a protected branch even if other protection rules are enabled, for example, when cleaning up old feature branches?
Explanation: Allow deletions permits users to delete protected branches despite other branch protection settings. Require pull request reviews only controls merging, not deleting. Disallow force pushes stops overwriting history, not deletion. Require status checks ensures test completion for merges, unrelated to branch deletion. Only allowing deletions provides explicit permission to remove protected branches.