Skip to content

Instantly share code, notes, and snippets.

@martinholub
Created May 17, 2021 18:52
Show Gist options
  • Select an option

  • Save martinholub/6cd65b770048ce0ab6c101dbcccab58e to your computer and use it in GitHub Desktop.

Select an option

Save martinholub/6cd65b770048ce0ab6c101dbcccab58e to your computer and use it in GitHub Desktop.

Revisions

  1. martinholub created this gist May 17, 2021.
    21 changes: 21 additions & 0 deletions master2main.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    # https://stevenmortimer.com/5-steps-to-change-github-default-branch-from-master-to-main/#step-3---point-head-to-main-branch

    # 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