Microsoft DevOps Engineer Expert (AZ-400) · Section 2 · 13% of the exam
Implement branch merging restrictions by using branch policies and branch protection rules
One of the objectives of the Exam AZ-400: Designing and Implementing Microsoft DevOps Solutions exam, in the section “Design and implement a source control strategy”. Here is what it covers, the points to remember and a question to try.
What it covers
A branch strategy decides how code flows from a developer's laptop to production. This lesson compares trunk-based development, feature branches and release branches, then shows how branch policies in Azure Repos and branch protection rules or rulesets in GitHub enforce pull requests, reviews, checks and allowed merge types.
Points to remember
- Trunk-based: short-lived branches, feature flags, deploy from main; feature branch: one branch per change merged by PR; release branch: release/* for supported versions.
- Release branches are not merged back by PR; fix in main and cherry-pick into release (Release Flow), or fix in release and cherry-pick to main.
- A required Azure Repos branch policy blocks direct pushes and branch deletion; changes go through PRs.
- Minimum-reviewers options: creator vote, most recent pusher, reset votes on new pushes, completion despite wait or reject votes.
- Build validation expiration choices: Immediately, After n hours, Never; path filters must start with / or a wildcard.
Try a question
A team follows Microsoft's release-branch guidance. A bug fix was made on release/20. The same fix must be applied to main without bringing over other release-specific changes. What should the team do?
- AMerge release/20 into main directly with a force push so the pull request history is preserved on both branches of the repository
- BMerge main into release/20 so both branches contain the same history
- CDelete release/20 and recreate it from main and then ask everyone to re-clone the repository
- DCreate a feature branch from main, cherry-pick the fix commit onto it, and merge it into main with a pull request
Show the answer
D. Microsoft recommends cherry-picking so you control exactly which commits return to main; merging the whole release branch can bring release-specific changes. The cherry-picked branch still goes through a pull request so main keeps its policies.
Written for practice in the style of the exam: never a question from the real exam.
In the course
The lesson Branch strategies, pull request workflows and merge restrictions teaches this objective (about 45 minutes), and 15 practice questions test it. The course has lessons, exam-style questions, timed practice exams and an AI tutor for every objective, and a pass prediction that tells you when you're ready to book.
More in this section
- Design a branch strategy, including trunk-based, feature branch, and release branch
- Design and implement a pull request workflow by using branch policies and branch protection rules
- Design and implement a strategy for managing large files, including Git Large File Storage (LFS) and git-fat
- Design a strategy for scaling and optimizing a Git repository, including Scalar and cross-repository sharing
- Configure permissions in the source control repository
- Configure tags to organize the source control repository
- Recover specific data by using Git commands
- Remove specific data from source control