---
title: Define a hierarchical structure for your Azure DevOps branches
description: I like my Azure DevOps branches to be well structured and well named. When we create a new ARM template a new feature branch is created based on the name o
---

[Uptec Blog](https://uptec.io/blog)

# [Define a hierarchical structure for your Azure DevOps branches](https://uptec.io/blog/require-folders-for-branches)

 Written by [Alexandre Verkinderen](https://uptec.io/blog/author/alexandre-verkinderen) | Dec 8, 2023, 2:32:00 AM

I like my Azure DevOps branches to be well structured and well named.

When we create a new ARM template a new feature branch is created based on the name of the template. This branch is short lived, typically only a few days and max 2 weeks. Once the development of the template is done, a pull request is created, the branch gets merged if all tests are passed and the branch gets deleted. We also have branches that will be created in the rare case a bug has been discovered in one of our ARM templates. These branches are even more short lived, typically only a few hours to maximum a few days.

We use the following naming convention for our branches:

- Feature/ARM-template-name
- Bugs/ARM-template-name

When working with lots of different people in the same AzDo project the number of branches can increase exponentially and it can quickly become a mess. Hierarchical branch folders is an easy solution to keep your branches clean and well structured. In Azure DevOps when you create a new folder with `/` it will automatically create that new branch under a folder.

The following standards have been defined in our AzDo environment:

- Only Dev and Master branch will be allowed to exist under the root
- Contributors will be forced to create new branches under the Features or Bugs folders

## Requirements

To be able to enforce folders in Azure DevOps we will need to use Team Foundation version control command (`tf.exe`). You can find tf.exe if you have installed Visual Studio in the following location: `C:\Program Files (x86)\Microsoft Visual Studio\2019\TeamExplorer\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer`. You will also need the AzDo organization name, the project name, the repository name and full permissions to change branch permissions. So in my case it is the following:

1. Organization Name = azurelns
2. Team Project Name = Todo
3. Repository name = Todo

## Enforce Branch Folder structure

Open the Developer Command Prompt, under Start > Visual Studio > Developer Command Prompt and go to the location of tf.exe.

First, let’s block the creation of new branches under the root

`tf git permission /deny:CreateBranch /group:[Todo]\Contributors /collection:https://dev.azure.com/azurelns/ /teamproject:Todo /repository:Todo`

Then allow contributors to create new branches under the Features folder

`tf git permission /allow:CreateBranch /group:[Todo]\Contributors /collection:https://dev.azure.com/azurelns/ /teamproject:Todo /repository:Todo /branch:Feature`

and the bugs folder

`tf git permission /allow:CreateBranch /group:[Todo]\Contributors /collection:https://dev.azure.com/azurelns/ /teamproject:Todo /repository:Todo /branch:Bugs`

Finally, allow administrators to create a branch called master and dev (in case it ever gets deleted accidentally) :man\_shrugging: .

`tf git permission /allow:CreateBranch /group:"[Todo]\Project Administrators" /collection:https://dev.azure.com/azurelns/ /teamproject:Todo /repository:Todo /branch:master`

`tf git permission /allow:CreateBranch /group:"[Todo]\Project Administrators" /collection:https://dev.azure.com/azurelns/ /teamproject:Todo /repository:Todo /branch:dev`

Now when I want to create a new branch directly under the root it will blocked as I’m not following the correct naming convention.

To create this branch I would need to place it in a folder like this: “Feature/testbranch”

## Conclusion

When working with multiple people on a project it is important to define some kind of hierarchical branch structure. The Team Foundation version control command lets you enforce that structure.

Hope this helps, Alex

[View full post](https://uptec.io/blog/require-folders-for-branches)

```json
{
  "@context" : "http://schema.org",
  "@type" : "BlogPosting",
  "author" : {
    "@type" : "Person",
    "name" : "Alexandre Verkinderen"
  },
  "dateModified" : "2024-12-08T02:36:31.655Z",
  "datePublished" : "2023-12-08T02:32:00Z",
  "headline" : "Define a hierarchical structure for your Azure DevOps branches",
  "image" : {
    "@type" : "ImageObject",
    "height" : 60,
    "url" : "/hs/hsstatic/content_shared_assets/static-1.4092/img/default-amp-logo.png",
    "width" : 60
  },
  "mainEntityOfPage" : "https://uptec.io/blog/require-folders-for-branches",
  "publisher" : {
    "@type" : "Organization",
    "logo" : {
      "@type" : "ImageObject",
      "height" : 60,
      "url" : "/hs/hsstatic/content_shared_assets/static-1.4092/img/default-amp-logo.png",
      "width" : 60
    },
    "name" : "Uptec Blog"
  }
}
```