Change Git's Default Branch From Master
Change Git’s Default Branch From Master
Scott covered this nicely with links to topics that show how master originated from BitKeeper. There is evidence to strongly suggest it does pertain to the outdated, oppressive and perverse master/slave metaphor, rather than master-copy.
Edited 17th October 2020 (a bit late, I know!) , Git now lets you set a default branch for init, and GitHub now defaults to main.
But if you have an older repository, some of these steps remain relevant.
So, here are the steps I followed:
Move Master to Main
# maintain refs
git branch --move master main
# push to remote
git push -u origin main
Enter fullscreen mode Exit fullscreen mode
Change the Default on Remote
Now depending on your remote tool, this might differ.
GitHub
- Assuming you’ve pushed
mainfrom the steps above. - Go to your Settings
- Go to the Branches section
- Change “Default branch” from
mastertomain
GitLab
- Assuming you’ve pushed
mainfrom the steps above. - Go to your Settings
- Go to the Repository section
- Change “Default Branch” from
mastertomain
BitBucket
- Assuming you’ve pushed
mainfrom the steps above. - Go to your Repository settings
- Go to the Repository details section
- Change “Main branch” from
mastertomain
then…
- Go to the Branching model section
- Change “Development branch” from
mastertomain
Git Now Lets You Name a Default Branch
Git Init Doesn’t Let You Name a Default Branch
Edited 17th October 2020 Since git 2.28, you’ve been able to change your default branch using built-in git features.
git config --global init.defaultBranch main
Enter fullscreen mode Exit fullscreen mode
Summary
Sort of past the point about caring which side you fall on here. The evidence is there. Be your own teacher, make the world a better place.



