Change Git's Default Branch From Master

@lukeocodes 🕹👨‍💻 - Jun 24 '20 - - Dev Community

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

  1. Assuming you've pushed main from the steps above.
  2. Go to your Settings
  3. Go to the Branches section
  4. Change "Default branch" from master to main

GitHub change default branch from master to main

GitLab

  1. Assuming you've pushed main from the steps above.
  2. Go to your Settings
  3. Go to the Repository section
  4. Change "Default Branch" from master to main

GitLab change default branch from master to main

BitBucket

  1. Assuming you've pushed main from the steps above.
  2. Go to your Repository settings
  3. Go to the Repository details section
  4. Change "Main branch" from master to main

BitBucket change default branch from master to main

then...

  1. Go to the Branching model section
  2. Change "Development branch" from master to main

BitBucket change development branch from master to main

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.

. . . . . . . . . . . . . . . . . . . . . . . . . . .