In Git 2.28 you can change the default branch name from
master to whatever you want (the name
main seems to be a popular choice).
Set Your Default Branch Name
If you run the following from the command line
git config --global init.defaultBranch main
it will set the defaultBranch name to
main in your global git config file (typically
Now when you run
in a new directory, it should initialize a Git repo with the branch name
main. You can check the branch name with
What if it doesn’t work?
If you are using a version of Git less than
2.28, this setting will have no effect.
You can determine what version of Git you are running by running the following from the command line.
Leave a Reply