Master to main
Earlier today I finally managed to understand the process and then implement the renaming of the default branch in my GitHub repositories. This follows a relatively old controversy — all new repositories are now by default created with a “main” branch, rather than the old terminology “master”.
I think it’s one of those things that make you feel ashamed because you haven’t thought of that before or managed to act more swiftly since you realise it. But I’m glad I managed to fix, relatively easily, all my own repositories — in case you’re interested (and for my own future reference), here’s how you do it.
# To rename 'master' branch # see: https://github.com/github/renaming # https://stevenmortimer.com/5-steps-to-change-github-default-branch-from-master-to-main/ # 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