The ability to use an alternate name for the primary branch began in git release 2.28. There are several ways to update git. I used Homebrew on a Mac.
NOTE: The version didn't change even though brew installed the latest version. If this happens, you may need to update the PATH. I did the following to fix the problem.
Add the following line near bottom of this file...
and execute the following to activate this change...
NOTE: You have to execute the source command in every terminal tab or restart terminal to have it fully take effect.
Configure main as the default repository for all new repos
~/.git file and adds the following lines...
Create repo with new default branch name
Add repo to GitHub
Create the repo in GitHub without adding any files (README, License, .gitignore). If you allow Github to add files, they will be added to the master branch.
NOTE: All of this is listed on the new repo page in github when you create the repo. EXCEPT the last line which specifies main as the branch instead of the default master branch provided by github.
Observations and confirmations:
- Refresh repo page in GitHub and you will see the main branch selected with README.md as the only file.
- Selecting the branch drop down list, you will see that main is the only branch.
- ... → Settings → Branches
- under the Default branch section, you will see "The default branch is set to main."