Force a branch naming convention in Azure DevOps Git

TFS 2018 and Azure Repos allow you to require branches be created in folders.

See for instructions how to configure permissions to enable this.

There are two kinds of git hooks:

  • Client-side hooks, works for the local git repo.
  • Server-side hooks, works for the remote repo (VSTS git repo as you used).

More details about git hooks, you can refer Customizing Git - Git Hooks in git book.

For now, only client-side hooks (such as pre-push hook, pre-commit hook etc) are supported for VSTS git repo.

The Server-side hooks is not available for now (but already in our backlog) for VSTS git repo, you can also find it in this user voice. Once server-side hooks are available in future, such as you can use pre-receive hook (or post-receive hook) to check and force convert branch name in remote repo.

Besides, the link in your question is using VSTS web hook which is quite different from git hooks. And of course you can check and force convert branch name by web hook, but you additional website to receive information and convert branch name. Detail steps as below:

Add a web hook in VSTS service Hooks Tab -> Trigger by code push event -> input your own website url -> Test -> make sure it can connect successful -> Finish.

Once new changes are pushed to VSTS git repo, the web hook will be triggered, and send information to your website. Then you can check and convert branch name in your website and push again.