DEV Community

Cover image for Converting a Git master Branch to main
Kristen Kinnear-Ohlmann
Kristen Kinnear-Ohlmann

Posted on • Originally published at

Converting a Git master Branch to main

Many organizations began to be aware of and change non-inclusive language in the second decade of the 21st century. Many of those changes affected technology, including the choice for git to replace master with main for the default repo branch to avoid connotations with slavery.

While GitHub took actions to ensure new repos created on the site used main, older projects still used master as the default branch. In addition, some generator libraries still create new projects with master as the default and Azure DevOps also creates new repos with master as the default.

I had some time between projects at work in the last week and I wanted to tackle making the change for some organization repos I created to manage SQL objects and SSIS projects. This will allow all developers and contributors to have a common reference regardless of repo. There is a small process involved in making the change, as well as communicating the change to any other developers or contributors to the repo.

Rename master to main and push to remote

  • In the local environment, open a terminal and navigate to the project to be updated
  • Move (rename) the master branch to main
git branch -m master main
Enter fullscreen mode Exit fullscreen mode
  • Push the new branch to the remote
git push -u origin main
Enter fullscreen mode Exit fullscreen mode

Reset default branch on GitHub

I use GitHub for my personal projects.

  • Choose Settings > Branches; master will display as the default branch GitHub master as default
  • Click the arrows icon to Switch to another branch GitHub switch to another branch as default
  • Select the new main branch and click Update GitHub select main branch
  • Acknowledge the warning for changing the default branch (ideally, you will communicate separately with others working in this repo that the default branch has changed) GitHub acknowledge warning
  • A message will display confirming the change GitHub default branch changed
  • Review the branches for the project and confirm that main is set as the default GitHub main default

Reset default branch Azure DevOps

My organization uses Azure Devops for version control.

  • Choose Repos > Branches Azure DevOps branches
  • Click the 3 dots menu on the main record and choose Set as default branch Azure DevOps set main as default
  • Confirm the change to main as the default branch Azure DevOps confirm main


In each case, I plan to leave the master branch in place for about a week before removing it. At my work organization, I am in the process of informing other contributors about the need to change to using main.

Top comments (4)

gnsp profile image
Ganesh Prasad

I'm so inspired and moved by this corporate (pronounced Microsoft) backed brilliant idea about changing terminology related to "slavery" (really, talk about underpaid and overworked "employees" in countries like India) that henceforth I'm gonna call my MasterCard "MainCard", a Master's Degree "Main's Degree" and I'll try not to master the art of sarcasm, rather I'm gonna try to main it.

ebitzu profile image

Since when is 'master' synonym with slave owner?

gueyenono profile image
gueyenono • Edited

What a generation we live in :(

huzairuje profile image

exactly, i still don't get it the migration from master to main branching