Avatar
Fernando Vásquez is an electronics engineer and software developer currently based in the world. He occasionally blogs about Python and Android programming.

Migrate Master Branch to Main

In order to replace your master branch and start using main instead. I found this steps be the simplest way to do it:

  1. Create the main branch locally, taking the history from master

     git branch -m master main
    
  2. Push the new local main branch to the remote repo

     git push -u origin main
    
  3. Switch the current HEAD to the main branch

     git symbolic-ref refs/remotes/origin/HEAD refs/remotes/origin/main
    
  4. Change the default branch on Github/Gitlab to main

  5. Delete the master branch on the remote

     git push origin --delete master
    

Why should I change master to main? Wikipedia Article

all tags