I've been seeing a lot of talk lately about renaming the default GitHub branch to
main. I think this is a really good idea! Something simple that promotes inclusion is always something that I will support. Thankfully, Git branches are built to make changes like this extremely easy. In this (very short) post, I'll show you how to rename your main Git branch to
main, and how to update the default branch on GitHub. Overall, this should take you about five minutes total. Just five minutes!
First, here's the commands to change your default branch name to
git branch -m old_branch_name main git push --set-upstream origin main
The first command renames
old_branch_name (your default branch name here, whatever that may be) to
main. The next branch pushes that new main branch to the remote. Replace
origin with whatever remote you use for your main repo host. Once you run these commands, you'll have your brand new
main branch. Isn't that cool!
If you're using GitHub like I am, then updating your default branch is a little bit more involved. First, navigate to Your Repo → Settings → Branches. There, you should be able to change the default branch to
If you don't want to keep the old branch name around, you can easily delete it (after all, it was easy enough to create!). Navigate to the root of your repo and click on the branches icon (the one with the number of branches your repo has). You should then be able to delete your old branch name.
Congrats, you've now renamed your default branch to
Top comments (1)
👏 I have started renaming my
masterbranches as well. I think anything that makes a project more welcoming is a good thing. Honestly its so simple to do, I really don't understand the uproar. I went ahead and renamed master in all of my blog posts and routes as well as the repo itself.
Master No More
Waylon Walker ・ Jun 15 ・ 3 min read