Git Your Master Branch to Main

Github has recently changed their default branch from “master” to “main” and with a few simple steps, you’ll be able to update your master branch too.

The easiest way to do this is to simply set the default name for the branch as “main” on github itself.

Incredibly simple, but what about older repositories that are already set up with “master”?

While still on github, select the repository you want to change. From withing the “Settings” tab, select “Branches” and rename “master” to “main”.

After this you should be greeted with a prompt informing you how to change your local branch:

All that is left to do is to simply follow the commands that github has provided:

And finally:

Now you are set using the main branch!



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store