Branch on new git repo locally
The default branch for git is set to master.
You can change that behavior by changing a global setting for the default branch.
This will help keep the main branch as the default for newly created repositories.
git config --global init.defaultBranch main
Renaming the default branch for an existing projects
git branch -m master main
git fetch origin
git branch -u origin/main main
git remote set-head origin -a
While creating a new repository on the remote
This is primarily a solved problem on remotely created repositories.
GitHub: The default branch name for new repositories is now main.
GitLab: If no custom default branch name is set at any level, GitLab defaults to main.
Bitbucket: https://community.atlassian.com/t5/Bitbucket-questions/How-to-change-MAIN-branch-in-BitBucket/qaq-p/977418.