In Azure Repos, teams choose a branching strategy to manage how code is written and integrated. The three main models are trunk-based development, feature branch development, and release branch development. The choice depends on team size, how often you release software, and your level of testing automation. Each model affects how developers collaborate and how quickly you can deliver updates.
With trunk-based development, all developers commit their code directly to a single central branch, usually called main. This approach encourages frequent integration, often multiple times a day, which helps avoid large, difficult merge conflicts. However, because everyone works on the same branch, this model relies heavily on automated testing to catch bugs right away. Teams must use strong continuous integration (CI) pipelines to check every commit and keep the main code stable.
The feature branch model isolates new work by having developers create a temporary branch for each new feature or bug fix. Developers can write and test their code in this isolated space without affecting the main branch or other team members. When the work is done, they submit a pull request to merge the changes back into main. This workflow creates a clear checkpoint for code reviews, allowing the team to discuss and approve changes before they become part of the shared codebase.
Teams use a release branch strategy when they need to support multiple live versions or require a dedicated stabilization phase before deployment. A release branch is created from the main branch when the software is nearly ready to ship. This isolates the release from ongoing feature development. Critical bug fixes can be applied directly to this release branch without stopping new work in main. This separation ensures a stable deployment environment and makes it easier to manage different versions over time.
To protect the codebase, administrators set up branch policies in Azure Repos. These policies act as quality gates, enforcing rules like requiring a minimum number of reviewers for a pull request or demanding that all code passes automated build checks before a merge. Teams should also use clear naming conventions to keep the repository organized. By combining these policies with automated CI/CD pipelines, teams can run security checks, execute tests, and deliver updates with less manual work.
Branch policies are rules in Azure DevOps that ensure code quality and secure workflows when merging changes through pull requests. They act as quality gates that block a merge until every condition is met, protecting important branches from unauthorized or low-quality code. These policies automate consistent standards so teams don't have to rely on manual checks.
A policy can require a minimum number of reviewers to approve a pull request before it merges. It can also enforce required successful builds, meaning the automated build pipeline must pass first. Merge strategies control how the code is integrated, such as using a squash to combine commits or a rebase to reapply commits on top of the target branch. Additional settings can block unresolved comments or require linked work items to improve traceability. Path filters let the policy apply only to specific folders or file types, which is useful for applying different rules to different parts of the code.
Branch policies are rules you set on important branches, like your main branch, to control how code is merged. They act as a quality gate, ensuring every change meets your team's standards before it joins the official codebase.
You can create several key policies. A minimum reviewers policy requires a set number of team members to approve a pull request, which helps spread knowledge and catch errors. A successful build validation policy forces the code to pass automated builds and tests in your pipeline, preventing broken code from being added. You can also define specific merge strategies, like requiring a squash merge, to keep the branch history clean.
Beyond policies, you can lock a branch down with protections. These settings stop people from bypassing your rules. Key protections include blocking force pushes, which prevents someone from overwriting the branch's commit history, and blocking direct commits, which ensures every change must come through a reviewed pull request. This keeps the branch's history reliable and forces all work through your approved process.
Seeking the thrill of transformative tech? Explore the art of designing and implementing DevOps solutions on Azure. Master the shift towards CI/CD, testing, and delivery, while preparing for the Designing and Implementing Microsoft DevOps Solutions exam!
Prepare and test your skills

Prepare and test your skills

The three main branching models in Azure Repos are trunk-based development, feature branch development, and release branch development. The choice depends on team size, release frequency, and the level of testing automation.
In trunk-based development, all developers commit directly to a single main branch, relying on frequent integration and automated testing. In feature branch development, developers work in isolated temporary branches and merge via pull requests, creating a checkpoint for code reviews.
A release branch isolates a version of software that is nearly ready to ship from ongoing feature development in the main branch. This allows for a dedicated stabilization phase and makes it easier to apply critical bug fixes to the release without stopping new work.
Branch policies act as quality gates that block a merge until conditions are met, such as requiring a minimum number of reviewers or a successful automated build. They can also enforce merge strategies, block unresolved comments, and require linked work items for traceability.