$ git config --global init.defaultBranch main
$ cp -r /usr/share/git-core/templates ~/Templates/git.git
$ git config --global init.templateDir '~/Templates/git.git'
$ echo 'ref: refs/heads/main' > ~/Templates/git.git/HEAD
Reference: https://superuser.com/questions/1419613/change-git-init-default-branch-name
$ git branch -m master main
$ git push -u origin main
$ # update local clones:
$ git checkout master
$ git branch -m master main
$ git fetch
$ git branch --unset-upstream
$ git branch -u origin/main
$ git symbolic-ref refs/remotes/origin/HEAD refs/remotes/origin/main
Reference: https://www.hanselman.com/blog/EasilyRenameYourGitDefaultBranchFromMasterToMain.aspx