Migrate Master To Main

less than 1 minute read

Description:

This post is documents how I updated my git repositories to rename from master to main and to update terminology when explaining things to IT people. See here and here for a background.

To Resolve:

  1. First, for each repo on your computer, cd into the repo and run:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    
    # Step 1 
    # create main branch locally, taking the history from master
    git branch -m master main
    
    # Step 2 
    # push the new local main branch to the remote repo (GitHub) 
    git push -u origin main
    
    # Step 3
    # switch the current HEAD to the main branch
    git symbolic-ref refs/remotes/origin/HEAD refs/remotes/origin/main
    
    # Step 4
    # change the default branch on GitHub to main
    # https://docs.github.com/en/github/administering-a-repository/setting-the-default-branch
    
    # Step 5
    # delete the master branch on the remote
    git push origin --delete master
    
  2. Keep a mental note to use the new terms:

    1
    2
    3
    4
    
    master => main
    slave => secondary
    whitelist => allowlist
    blacklist => blocklist
    

Comments