Forrest logo
back to the az tool

az-repos:tldr:af343

az-repos: Add policy on a specific branch of a specific repository to restrict basic merge.
$ az repos policy merge-strategy create --repository-id ${repository_id_in_repos_list} --branch ${branch_name} --blocking --enabled --allow-no-fast-forward false --allow-rebase true --allow-rebase-merge true --allow-squash true
try on your machine

This command creates a merge strategy policy for a specific repository and branch in Azure DevOps using the az repos policy merge-strategy create command.

Here's a breakdown of the command and its options:

  • --repository-id ${repository_id_in_repos_list}: Specifies the ID of the repository where the merge strategy policy will be created. ${repository_id_in_repos_list} is a placeholder for the actual repository ID.
  • --branch ${branch_name}: Specifies the name of the branch where the merge strategy policy will apply. ${branch_name} is a placeholder for the actual branch name.
  • --blocking: Specifies that the merge strategy policy should block the merge if it doesn't adhere to the configured rules.
  • --enabled: Specifies that the merge strategy policy should be enabled.
  • --allow-no-fast-forward false: Disallows non-fast-forward merges. A fast-forward merge is when the branch being merged into has no additional commits since the creation of the branch being merged. Setting it to false means that non-fast-forward merges are not allowed.
  • --allow-rebase true: Allows the rebase merge strategy. This means that branches can be rebased onto the target branch during a merge.
  • --allow-rebase-merge true: Allows the rebase merge strategy with merge commits. This means that branches can be rebased onto the target branch and generate merge commits during a merge.
  • --allow-squash true: Allows the squash merge strategy. This means that branches can be squashed into a single commit on the target branch during a merge.

Overall, this command creates a merge strategy policy that allows rebase, rebase with merge commits, and squash strategies while disallowing non-fast-forward merges for a specific repository and branch.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the az tool