Interview Q&A / Git & GitHub

BeginnerQuick answer1 min readUpdated 3 Oct 2026

What is branch protection on GitHub, and what rules can you set?

SHORT ANSWER

Branch protection rules guard important branches like main. You can require pull requests, a number of approvals, passing status checks, up-to-date branches, and block force pushes and deletion.

Explain it simply

Branch protection is a lock on the main gate: nobody walks in directly, not even the senior developer on a busy day.

Under Settings, Branches, you add a rule for main. Typical options: require a pull request before merging, require one or two approvals, require status checks like tests to pass, require conversations resolved, require linear history, and block force pushes. You can apply rules to administrators too. This ensures every change is reviewed and tested before reaching production.

Example

text
Rule for: main
[x] Require a pull request before merging (1 approval)
[x] Require status checks to pass: tests, lint
[x] Block force pushes
[x] Do not allow deletion

What to say in the interview

"Branch protection enforces rules on a branch such as main: required pull requests and approvals, passing status checks, no force pushes or deletion. It guarantees that nothing reaches main without review and green tests."

#github#branch-protection#security

Related questions

Practise more Git & GitHub questions

Test your recall with short answers, then return to the detailed explanations when you need context.

Open Git & GitHub quick answers →

Get new questions like this by email

One short email when something new and useful lands. No spam, unsubscribe in one tap.

By subscribing you agree to the Privacy Policy.