Cross-repository policies in Azure DevOps

In Azure DevOps, effective management of repositories involves implementing robust policies. One powerful feature at your disposal is Cross-Repository Policies. In this guide, I’ll walk you through the process of adding these policies to your DevOps project. 

To perform the steps described in this article you need to be a Project Administrator.

How to add a cross-repository policy

Let’s say our standard repository comes with a main and develop branch.  Work is done in feature branches, then merged to the develop branch in a Pull Request. When ready to be released, it’s merged to the main branch. All PRs must be reviewed by two people other than the requestor of the Pull Request. The main branch is our default branch.

We want to set a policy on these branches without having to specify them individually for every single repository within our DevOps project.

This is where the cross-repository policy comes in. Cross-repository policies provide a way to enforce uniform policies across branches, and are scoped to a project.

Navigate to the cross-repository policies

On the main page of the DevOps project click ‘Project Settings’ (1), located in the bottom left corner of the page.

When in the Project Settings click ‘Repositories’ in the index, under Repos (2)

From there click the policies link (3) under All repositories and you’ll find the ‘Branch policies’ under the ‘Repository Policies’

1. ‘Project settings’ link 

2. ‘Repositories’ item   

3. Link to the ‘Policies’ tab  

Creating the policies

Click the plus-sign in the top-right corner of the branch policies overview to add a new policy (4)

4. The ‘Branch Policies’ overview

Here you can choose to protect the default branch of each repository or to protect branches matching a pattern.

First enable a policy on the default branch of each repository. Select ‘Protect the default’ branch of each repository (5) and click create.

5. Available options for Branch protection

Then add the desired option for this policy: requiring a Pull Request to be reviewed by two persons other than the requestor (6) Now the policy is finished. There’s no save button here, changes are saved immediately without having to explicitly save them.

6. Setting the ‘Require a minimum number of reviewers’ option

So now we have one policy protecting the default branches. In addition, we would also like to protect the develop branch of each repository.

Return to the policy overview, click the plus-sign, and now select ‘Protect current and future branches matching a specified pattern’ and specify a branch pattern.  In our case, the pattern is ‘develop’. (7) As you can see, four matching branches are found across the repositories in my project.

7. Setting a policy on all ‘develop’ branches

Then click create and set the ‘Minimum number of reviewers’ option for the policy and we are done. All default branches and branches matching the pattern specified, will be subject to the policies we have created within the project settings.

When you look at a policy  on a  specific branch  a label is added next to a policy item, stating that the setting is inherited (8)

8. The reference to the inherited policy

How to delete a cross-repository policy

There’s no delete button for this action. A policy can be deleted by turning off all requirements for the cross-repo policy.

Steps to take

Go to the policy in ‘Project settings’ > ‘Repositories’ > ‘Policies’ and select the policy.

Turn off all ‘Branch policies’, remove items from ‘Build Validation’, ‘Status checks’, and ‘Automatically included reviewers’.

To delete the policy we have created for the develop branch of each repository, turn off the setting ‘Require a minimum number of reviewers’.

Now click the “back-button” next to the title at the top of the page and, presto, the policy for develop has been removed (9) Only the ‘[default branch]’ policy remains.

9. After removing all options from the ‘develop’ policy, only ‘[default branch]’ remains

Removing the default branch policy can be done in the same way.


This guide provided insights into setting up cross-repository policies in Azure DevOps to ensure uniform branch management across projects. It covered the steps for adding, configuring, and deleting policies, offering an efficient way to maintain consistency in development workflows. Implementing cross-repository policies contributes to a more organized and adaptable approach to project requirements in Azure DevOps.