AZ-400 Question 61
Single answerYou are a DevOps engineer for a company that is migrating its source code to Azure Repos. The team wants to keep the main branch stable, use feature branches for new work, merge changes frequently to avoid large merge conflicts, and handle production hotfixes quickly. Which of the following branching strategies best meets these requirements?
- A
Adopt GitFlow with a long-lived develop branch and feature branches merged into develop before releases.
- B
Use trunk-based development with short-lived feature branches that merge back to the main branch frequently.
- C
Maintain a single main branch where all developers push their changes directly for continuous delivery.
- D
Create separate repositories for new features and merge them into the main repository only during release cycles.
Show answer and explanation
Correct answer: B
Explanation
Trunk-based development with short-lived feature branches meets the requirements of keeping the main branch stable, frequently merging changes to avoid large conflicts, and enabling quick hotfixes directly from main if urgent issues arise. Microsoft� branching strategies guidance (see docs.microsoft.com) supports using short-lived branches to maintain a streamlined, continuous integration process.
- A. Incorrect.
Option 1 (GitFlow) is a robust strategy with a separate develop branch, but it can introduce longer-lived branches and larger merges. For rapid updates and hotfixes, GitFlow can be more complex than necessary if the release cycle is frequent.
- B. Correct.
Option 2 (trunk-based development with short-lived feature branches) is correct. It encourages frequent merges back to the main branch, reduces merge conflicts, and allows quick hotfix branches from the main branch if needed.
- C. Incorrect.
Option 3 (single main branch with direct pushes) often leads to instability, as multiple developers pushing directly to main can cause unexpected issues. It lacks the isolation and safety of feature branches.
- D. Incorrect.
Option 4 (separate repositories for new features) complicates integration and increases overhead. Merging changes across multiple repos is more cumbersome than using short-lived branches in one repository.