๐ How to Change the Default Branch from master
to main
in Azure Repos (Azure DevOps)
Changing the default branch from master
to main
is now a widely adopted best practice for inclusivity and modern development workflows. If you’re working with Azure DevOps Repos, this blog will guide you through renaming your master
branch to main
and updating all related settings seamlessly.

๐งฉ Why Rename master
to main
?
Before we get into the steps, letโs understand why many teams are making this shift:
- ๐ Modern Standards: GitHub, GitLab, and Azure DevOps now recommend
main
as the default branch name. - ๐ค Inclusivity: Moving away from legacy terminology improves tech culture.
- ๐งช Tool Compatibility: Modern CI/CD tools default to
main
.
๐ง Step-by-Step: Rename and Set main
as Default Branch
โ
Step 1: Rename master
to main
You can do this either through the Azure DevOps UI or your local Git terminal.
๐ฅ๏ธ Option A: Rename via Azure DevOps UI
- Navigate to your Azure DevOps project.
- Go to Repos > Branches.
- Locate the
master
branch. - Click the three dots (โขโขโข) beside it.
- Select Rename and change the name to
main
.
๐ป Option B: Rename Using Git Command Line
# Rename the local branch
git branch -m master main
# Push the renamed branch
git push -u origin main
# Optionally delete the old branch from remote
git push origin --delete master
๐งญ Step 2: Set main
as the Default Branch
Once renamed, youโll need to make main
the default branch for your Azure Repo:
- In Azure DevOps, go to Repos > Branches.
- Click the three dots (โขโขโข) next to the
main
branch. - Select Set as default branch.
๐ก๏ธ Step 3: Update Branch Policies
If you had any branch policies (e.g., PR reviews, build validations) applied to master
, make sure to:
- Go to Project Settings > Repositories > Branch Policies.
- Reconfigure those same policies for the new
main
branch.
๐ Step 4: Update Pipelines and Workflows
๐งฌ For YAML Pipelines:
Open your azure-pipelines.yml
and update:
trigger:
branches:
include:
- main
๐๏ธ For Classic Pipelines:
- Navigate to your pipeline in Azure DevOps.
- Open the Triggers tab.
- Change the default branch from
master
tomain
.
๐ Final Tips
- ๐งช Test Everything: Run your pipelines and validate deployments after renaming.
- ๐ Check Permissions: Make sure service accounts and developers have access to the
main
branch. - ๐ Communicate: Notify your team about the branch name change to avoid confusion.
๐ฏ Conclusion
Renaming your default branch to main
in Azure DevOps is a straightforward task that aligns your project with current industry standards. By following the above steps, you ensure a smooth transition without disrupting your CI/CD or collaboration workflows.
๐ก Pro Tip: Always create a backup or tag your current state before performing major changes in your repository.
Leave a Reply