Bitzu

GH-900 ยท Security and administration

Branch protection rules

Required reviews, required status checks, restricting force pushes and deletions on important branches, and how rulesets relate.

Key points

  • Branch protection guards important branches such as main.
  • You can require pull request reviews (a set number of approvals, optionally from code owners), require status checks to pass before merging, block force pushes and deletions, and require linear history or signed commits.
  • Only one branch protection rule applies to a branch at a time, while rulesets are the newer, layered alternative that can be combined.

Source: https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/managing-protected-branches/about-protected-branches

Practice questions

Single choice

Which branch protection option makes sure automated tests succeed before a pull request can be merged?

  1. Require status checks to pass
  2. Block force pushes
  3. Require signed commits
  4. Restrict deletions
Show answer

Answer: A. Require status checks to pass

Required status checks block merging until the named checks pass. Required reviews involve human approval, and blocking force pushes protects history.

Select all that apply

Which protections can be applied to an important branch?

  1. Require approving reviews on pull requests
  2. Require status checks to pass before merging
  3. Restrict force pushes
  4. Automatically translate the README
  5. Require an emoji in every commit message
Show answer

Answer: A. Require approving reviews on pull requests, B. Require status checks to pass before merging, C. Restrict force pushes

Required reviews, required status checks and blocking force pushes are all branch protection options. Automatically translating the README and mandatory emoji commits are not.

True or false

True or false: by default, admins and roles with the bypass permission are always subject to branch protection rules.

Show answer

Answer: False

False. Admins can bypass by default; the option to not allow bypassing must be enabled for the rules to apply to them too.

Practice 8 questions on this topic in Bitzu

Short lessons, instant explanations and spaced review of what you get wrong. Free on iOS and Android.

Download on the App StoreGet it on Google Play

More GH-900 topics in this module