az-repos
Manage Azure DevOps Git repositories
TLDR
List all repos in a specific project
Add policy on a specific branch of a specific repository to restrict basic merge
Add build validation on a specific repository, using an existing build pipeline, to be triggered automatically on source update
List all active Pull Requests on a specific repository within a specific project
SYNOPSIS
az repos <subcommand> [--organization] [--project] [--output (-o)] [--query (-q)] [--subscription] [--verbose] [--help]
PARAMETERS
branch
Manage branches in a repository.
create
Create a new repository in a project.
delete
Delete a repository.
list
List repositories in a project.
prune
Delete empty or unused repositories.
show
Show details of a specific repository.
update
Update repository properties like name or default branch.
DESCRIPTION
The az repos command is part of the Azure CLI for managing Git repositories in Azure Repos, a service within Azure DevOps Services or Server. It enables creation, deletion, listing, updating, and inspection of repositories, branches, files, and folders.
Requires the azure-devops extension: az extension add --name azure-devops. Authenticate with az login or a Personal Access Token (PAT) via --token.
Key uses include automating repo lifecycle in CI/CD pipelines, scripting project setups, and integrating with tools like Git. Specify --organization (e.g., https://dev.azure.com/org) and --project for operations. Supports JSON, table outputs via --output. Permissions like 'Contributor' or specific repo scopes needed.
Ideal for DevOps teams handling multiple projects without web UI.
CAVEATS
Requires azure-devops extension and Azure DevOps permissions. Most subcommands need --organization and --project. PAT must have 'Code (read/write)' scope. Not for GitHub or other providers.
INSTALLATION
az extension add --name azure-devops
az extension update --name azure-devops for latest.
AUTHENTICATION
Use az login --tenant <tenant> or --token <pat>. PAT from Azure DevOps user settings.
EXAMPLES
az repos list --organization https://dev.azure.com/myorg --project myproject --output table
az repos create --organization https://dev.azure.com/myorg --project myproject --name myrepo
HISTORY
Added via Azure DevOps CLI extension in 2018, evolved with Azure CLI v2.x updates to match Azure DevOps features like multi-repo support and branch policies.


