Goodbye Git Master Branch
Switching off the git master
branch was easier than I expected!
Changes are coming…
I had heard about the controversy
about git’s master
branch. I didn’t have a strong emotional attachment to the name… so I decided to switch and see what happens.
It seems like main
is the consensus for the new branch name:
- it’s short
- it’s easy on muscle memory (has the same first 2 letters)
- it translates well to most languages
Let’s switch everything to main
.
New Repositories, on GitHub
Since October 2020, GitHub creates new repositories with main
as the default branch.
Done ✅
New Repositories, locally
Since git 2.28, there’s a new config setting for the default branch name on newly created repositories:
Done ✅
Existing Repositories…
It took a few tries to find a recipe that I was happy with.
For each repository, pick one clone:
and for all your other clones:
I audited all my local repositories and had the chance to practice on over 20 projects. ✅
Then, I remembered to repeat on all my computers. ✅
Your own local audit
If you’ve been accumulating clones over time, it’s easy to lose track of ALL the git repositories you have hanging around. This can be a good start:
If you save the output to a file, you can bootstrap the next phase: checking “ownership”
You’ll want to adjust this to your own git remote names, usernames, etc
Consequences
Everything just worked … which wasn’t what I was expecting. I was planning on breaking something… researching and fixing problems over time. 😅
Intellectually, I understood that commits matter, but branches are just convenient names. Of course, branches can have different names locally and remotely … (although I never thought that would be a good idea)
References
Sounds too easy? Not sure? Here are some of the pages that helped me: