🔁 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
mainas 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
masterbranch. - 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
mainbranch. - 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
mainbranch.
🔁 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
mastertomain.
📝 Final Tips
- 🧪 Test Everything: Run your pipelines and validate deployments after renaming.
- 📁 Check Permissions: Make sure service accounts and developers have access to the
mainbranch. - 🚀 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.