gitazure-devopsbranchpull-requestazure-repos

Force a branch naming convention in Azure DevOps Git


We use Git hosted in Azure DevOps for all of our source code. So far we have used Git Hooks to ensure that team members follow a branch naming convention {branchtype}/{username}/{friendlyname}/{workitemtype}{workitemid}.

Examples:

The branch naming convention allow us to clearly understand whether it's a regular development branch or a hotfix branch and which work item it is associated with, among other things.

To setup Git Hooks locally, team members were required to run a script locally before starting to contribute. This was fine as the script was doing additional setup besides just setting up Git Hooks. But we don't need that additional setup anymore and therefore we are looking to remove the script completely.

Is there a way to force branch naming conventions on the server side?

I noticed there is documentation for Pull Request Status Server, but was wondering if there is something OOTB which just needs to be configured in Azure DevOps.


Solution

  • A little late as an answer - looks like this has been introduced now at a project level.

    Link to the (not very good) documentation

    In the project settings, go to Repositories and branch policies enter image description here

    Click the [+] button and you can specify a branch name pattern for all GIT repos

    enter image description here

    This should answer the part of the question you asked that I do not believe was completely answered before. Is there a way to force branch naming conventions on the server side?