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…


This content originally appeared on DEV Community and was authored by Kristen Kinnear-Ohlmann

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
  • Push the new branch to the remote
git push -u origin main

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

Post-conversion

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.


This content originally appeared on DEV Community and was authored by Kristen Kinnear-Ohlmann


Print Share Comment Cite Upload Translate Updates
APA

Kristen Kinnear-Ohlmann | Sciencx (2021-11-15T02:58:56+00:00) Converting a Git master Branch to main. Retrieved from https://www.scien.cx/2021/11/15/converting-a-git-master-branch-to-main/

MLA
" » Converting a Git master Branch to main." Kristen Kinnear-Ohlmann | Sciencx - Monday November 15, 2021, https://www.scien.cx/2021/11/15/converting-a-git-master-branch-to-main/
HARVARD
Kristen Kinnear-Ohlmann | Sciencx Monday November 15, 2021 » Converting a Git master Branch to main., viewed ,<https://www.scien.cx/2021/11/15/converting-a-git-master-branch-to-main/>
VANCOUVER
Kristen Kinnear-Ohlmann | Sciencx - » Converting a Git master Branch to main. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/11/15/converting-a-git-master-branch-to-main/
CHICAGO
" » Converting a Git master Branch to main." Kristen Kinnear-Ohlmann | Sciencx - Accessed . https://www.scien.cx/2021/11/15/converting-a-git-master-branch-to-main/
IEEE
" » Converting a Git master Branch to main." Kristen Kinnear-Ohlmann | Sciencx [Online]. Available: https://www.scien.cx/2021/11/15/converting-a-git-master-branch-to-main/. [Accessed: ]
rf:citation
» Converting a Git master Branch to main | Kristen Kinnear-Ohlmann | Sciencx | https://www.scien.cx/2021/11/15/converting-a-git-master-branch-to-main/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.