Most of the guides to renaming the master
branch to main
(or whatever you choose) resort to asking you to to use the command line Git app to check out the repo, make the change and push it back up. That's fine if you're on your development machine with SSH keys added and everything set up, but what if you need to do this from a temporary workstation with no SSH keys or perhaps no Git even? What if you wish to do so using a portable device like your smartphone or an iPad?
I have a lot of repositories on GitHub, both public and private. Some of these are past projects that I don't have a local working copy of, so checking out and going through all those steps seems like a tedious task.
Thankfully, there is an easier way using the GitHub web interface that involves none of this. From the GitHub repo that you wish to do this for...
- Click on the branch button again and type in a name for the new branch, eg
main
. Ensure you're doing this while on themaster
branch. - Click on the branch button once more and then on View all branches.
- In the list of branches that shows up, next to your
master
branch, click on the button to Change default branch. - From the dropdown that shows up, pick the name of your new branch and click Update.
- Read the warning and click I understand, update the default branch.
You're done at this point, but you can and should also go and delete the master
branch.
- Click on the Code tab to return to the code.
- Click on the branch button and View all branches again.
- Click on the red trash can icon next to the
master
branch.
That's all it takes!
Thank you for making the world a better place. Stay safe and keep coding!
Top comments (0)