Front-End Web Daily
Tuesday Tips | How to Rename Your Master Branch on GitHub
Today is September 8, 2020, and for this Tuesday Tips episode we're covering How to Rename Your Master Branch on GitHub
Let's dive in!
----
Recent events have brought to light the negative connotations of having the main branch on a repository called master
. Whether you want to change your primary branch name for this reason or just for fun, it is important to know how to do so and there are a few key steps to ensure that the change goes smoothly.
----
Before we jump into changing our existing repos, let's make sure that we avoid the issue altogether in our future projects. In GitHub, under Settings > Repositories
there is an option to name your default branch for future projects. Remember, this changes it for your personal account, but you can do the same for an organization.
As a note, on October 1st of this year, GitHub will be setting the default branch for new repositories to main
.
----
Now, to change an existing repo to a new name add a new branch from the existing master
, which we will call main
for this example. With an exact copy now on main
go to the repository Settings > Branches
and change the default branch to main
. Then we can delete the master
branch, which will alert us that the open pull requests for master
will be affected. You can use a tool, like this one from Edward Thomson, to re-target the pull requests to the new branch.
And that's it! You've made the change away from the master
branch. If you still think it sounds a bit too complicated or too much work, GitHub announced that it will be releasing a feature to make a seamless transition when renaming the default branch by the end of the year.
----
Today's Tuesday Tips was adapted from a post on the DEV Community.
----
Want to know more? Head to fewdaily.com for more of today’s topics and other front-end web content! If you liked what you heard be sure to rate, review, and subscribe on your platform of choice. That's all for today, tune in tomorrow!
--- This episode is sponsored by · Anchor: The easiest way to make a podcast. https://anchor.fm/app