Recently, the CEO of GitHub responded to a Tweet about renaming default Git branches from master to main, saying, "It's a great idea and we are alr...
For further actions, you may consider blocking this person and/or reporting abuse
When I renamed and pushed the branch
main
, I needed to manually set upstream so that I did not get "Branch 'main' set up to track remote branch 'master' from 'origin'." So I did it differently.master
is up to date, thengit checkout -b main
git push -u origin main
main
git branch -d master
git push origin :master
Also, anyone that truly does not believe "that terms such as master, slave, and blacklist are racially-charged or have undesirable connotations", please make sure to add such beliefs to your github profile. Thanks
Also, too, anyone who (NOT anyone 'that') truly or otherwise does not realize "that terms such as master, slave, and blacklist" exist for more reasons than your simpleminded understanding can deal with - too bad.
Thanks for this -- nice & easy to follow.
After I did this, on my other clones of the repo, after following your instructions, I needed to do
git remote prune origin
to remove refs to the staleorigin/master
.I made a tool that calls the GitHub API and automatically changes the default branch for all of your GitHub repositories remotely. Then all you have to do is pull the changes into your local repositories. Let me know what you think, and if you like it, please add it to your blog post! eyqs.ca/tools/rename/
The tool you wrote is very neat! I thought about making a tool that just does the "patch" part (changing the default branch) but in the end I opted to just change them all manually since it didn't take long. However, I'm sure your tool could be handy for others, especially if there are a lot of repos to go through.
Thank you for the kind words! Do you mind if I add your reply as a testimonial on the project page?
No problem!
Thank you for this post. I have used this so many times. The instructions are super easy to follow. I have needed both sets. I have renamed master to main and then worked on repositories where I already had a local repository and someone else renamed it. Just wanted to say thank you.
For anyone coming to this in January 2021, GitHub have a new feature to make this really easy. Under settings you can change the name of the primary branch. This preserves all open pull requests. When you make the change, they also give you the couple of commands that you need to run to update your local branch to match.
It's been the 300th time that I try to switch to "master" and it doesn't exist, because some bored idiot needed to do something that day, and decided that changing "master" to "main" for some made up reason was a good idea.
This whole assumption that "master" in the case of Git refers to "master/slave" is wrong, never seen "slave" branches before. Master can have meaning other than a "slave's master".
The "master/slave" architecture of course does exist, so does "master/worker" or other.
And so "blacklist/whitelist" exist... there is only one problem, who decided and when that this was all about black Americans? Are Americans really unable to realize that there is a world and a history outside of their country, and that the language they use comes from there?
Slaves outside of the US have been of every race, in fact, it was very common to enslave people of the same ethnicity, it would happen quite commonly, since they would be close by enough to be enslaved and become a resource to be used, it wasn't even a matter of hate, but of usage. Which is still an unacceptable thing, even thought it is what made us progress at a certain point in history and it engraved in human nature.
So a "master" is not a "white master and a black slave", and Americans being convinced that that's the case, only shows how egocentric they are.
Same goes for blacklists and whitelists, they don't come from allowing white people and not allowing black people. Yes, they are based on the concept that black is scary and bad, want to know why? Because up until not too many centuries ago night (the dark) meant danger, it meant predators, and more recently during the first part of the industrial revolution and previously it meant halting production, since lack of light, you know, makes it hard to work. That is why black is supposedly "bad", it has nothing to do with black people.
But of course, now that everyone magically feels uncomfortable we have to change industry standards right? We have to break scripts, defaults, and the workflow of people.
This is of course a general rant about changing an industry standard, which 2 years later, still comes to bite us in the a**. Of course, renaming branches is and always has been possible, and everybody can feel free to do it.
Nice post.
Hi, please add a warning that this will close all open pull requests instead of moving them to the new default branch.
I needed to run
on my other checkouts to make the old branch name go away.
Good article. Good information.
I agree 100% with you: " However, I hope we can all agree that it's always good to have the know-how and the tools to be able to change the names we use. "
This was really helpful, thank you.
I don't use Github much, so it took me a moment to find where to change the default branch. It is just under Settings>Branches