How to Set the Default Git Branch Name from Master to Main

preview_player
Показать описание
You can now chance the default Git init branch name from master to main or anything else you find more appropriate. The default branch name in GitHub for new repositories has already changed from master to main. You might want to make the same change to your own Git installation. Here I demonstrate how. But really, it's quite simple. Just a matter of issuing one of the following Git commands:

It's worth noting that the ability to change the default Git branch name from master to main is only available since the Git 2.28 release. If you're using an older version, to you won't be able to change the default Git init branch name from master and will instead need to change the branch name after the Git init has completed.
Рекомендации по теме
Комментарии
Автор

Awesome! Thank you for this, been searching for how to change this for the past hour... And you just explained it in a simple 3 minute video.

hiant
Автор

The best video, quickly, accurate and effective. Thank you Cameron

richigarciacastro
Автор

when I run this command I show two entries in my git config one init.defaultBranch=master and the second one is init.defaultBranch=main why?

LalitKumawat
Автор

Hello, I'm using this command, and also checked in "git config -l" it's also setted the init.defaultBranch=main, but when I "git init", it still starts the branch "master"
does anyone has any idea why???
Thank you!!

lucianocavallo
Автор

$git config --global init.defaultBranch main/master/your branch name

fake
Автор

thanks for the vid, also followed on twitter. #cameronGang

cameonjackson