Requiring One Approval and an Up-to-Date Branch Before Merge
Your organization uses GitHub for source control. You need to enforce that all pull requests require at least one approval and that branches must be up to date with the base branch before merging. Which branch protection rule settings should you enable?
Quick Answer
'Require a pull request before merging' with at least one required approval, combined with 'Require branches to be up to date before merging,' together enforce both conditions — the first blocks direct pushes and mandates a reviewed PR, and the second ensures the branch has been tested against the latest base-branch code before it's allowed to merge.
⚠ Common exam trap
A common mix-up: candidates think 'Require status checks to pass before merging' alone covers both the approval and up-to-date requirements, but it does not enforce the pull request workflow or the branch freshness check unless those specific status checks are explicitly configured.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
Require a pull request before merging and require branches to be up to date
GitHub branch protection rules allow you to enforce both that pull requests require at least one approval and that branches are up to date with the base branch before merging. The 'Require a pull request before merging' setting ensures that changes cannot be pushed directly to the protected branch and must go through a PR with required approvals. The 'Require branches to be up to date' setting (under 'Require status checks to pass before merging') ensures that the branch is tested against the latest base branch code, preventing stale merges.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Require branches to be up to date only
Why it's wrong here
Missing the pull request requirement.
- ✗
Require a pull request before merging only
Why it's wrong here
Missing the up-to-date requirement.
- ✗
Require status checks to pass before merging only
Why it's wrong here
This doesn't enforce pull request or up-to-date requirements.
- ✓
Require a pull request before merging and require branches to be up to date
Why this is correct
Both settings enforce the required policies.
Go deeper
Related to this question
Learn chapter
Source Control Strategy Design
Key term
Branch
A branch is a pointer to a specific commit in a version control system that allows you to work on features or fixes in isolation from the main codebase.
Key term
Pull request
A pull request is a way for a developer to propose changes to a codebase and ask other team members to review and merge them into the main project.
About these practice questions
One of 823 original AZ-400 practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →
Same concept, more angles
4 more ways this is tested on AZ-400
These questions test the same concept from different angles. Work through them to make sure you can recognise it however the exam phrases it.
Variation 1. Your organization uses GitHub Enterprise with a monorepo containing multiple microservices. Developers work on feature branches and create pull requests to merge into main. You need to implement a policy that ensures all pull requests have at least one review from a code owner, pass required status checks (CI build and unit tests), and are up-to-date with the latest main branch before merging. Additionally, you want to prevent direct pushes to main. Which combination of branch protection rules should you configure?
medium- A.Require pull request reviews before merging, require status checks, and restrict who can push to matching branches.
- B.Require pull request reviews before merging, require branches to be up-to-date, and restrict push access to admins only.
- C.Require status checks, require branches to be up-to-date, and include administrators.
- ✓ D.Require pull request reviews before merging, require status checks, require branches to be up-to-date, and restrict who can push to matching branches.
Why D: Option D is correct because it includes all required elements: requiring pull request reviews (which can be configured to require code owner reviews), requiring status checks, requiring branches to be up-to-date, and restricting who can push to matching branches to prevent direct pushes. Option A lacks the up-to-date requirement. Option B does include pull request reviews but lacks status checks and permits admin direct pushes. Option C lacks pull request reviews and does not restrict direct pushes, though it does include status checks.
Variation 2. Your team is using GitHub Flow for a web application. Developers create feature branches from main, make changes, and open pull requests. Recently, several pull requests were merged without required reviews because the branch protection rules were not enforced on the main branch. What should you do to ensure all pull requests to main require at least one reviewer?
medium- ✓ A.Enable the 'Require a pull request before merging' rule in branch protection for main, and set 'Required approvals' to 1.
- B.Configure the repository to automatically delete head branches after pull requests are merged.
- C.Enable the 'Require branches to be up to date' rule in branch protection for main.
- D.Add a CODEOWNERS file and configure it so that every file has at least one owner.
Why A: Branch protection rules in GitHub can enforce required pull request reviews before merging. By enabling 'Require a pull request before merging' and setting 'Required approvals' to 1, any pull request to main must have at least one reviewer approve before merging. Option B is incorrect because deleting head branches after merge does not enforce reviews. Option C is incorrect because requiring branches to be up to date is about ensuring the branch is current with the base branch, not about requiring reviews. Option D is incorrect because CODEOWNERS are optional and do not enforce mandatory reviews unless branch protection rules are set accordingly.
Variation 3. Your team uses GitHub Flow and wants to enforce that all pull requests require at least one approval before merging to the main branch. Which branch protection rule should you configure?
medium- A.Require status checks to pass before merging
- B.Restrict who can push to matching branches
- ✓ C.Require a pull request before merging with at least 1 approval
- D.Require linear history
Why C: It directly enforces the requirement for at least one approval before merging. 'Require a pull request before merging' must be enabled, and within that, 'Required approvals' should be set to 1. Option A (status checks) verifies CI passes, not approvals. Option B restricts who can push to branches, which is unrelated to approval requirements. Option D (linear history) enforces a linear commit history but does not mandate approvals.
Variation 4. Your team uses GitHub and wants to prevent direct pushes to the main branch. Only pull requests with at least one approval should be allowed to merge. Which GitHub feature should you use?
medium- A.Repository rulesets
- ✓ B.Branch protection rules
- C.CODEOWNERS file
- D.GitHub Actions
Why B: Branch protection rules are the GitHub feature that can prevent direct pushes and require pull requests to have at least one approval before merging. CODEOWNERS only requests reviews, and GitHub Actions does not enforce branch protection policies.
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This AZ-400 practice question is part of Courseiva's free Microsoft certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the AZ-400 exam.