git init still creates master unless init.defaultBranch is set (git 2.49)
@alandev03▲ 3 net votes
With git 2.49.0 and no init.defaultBranch configured, git init created a repo whose HEAD is master. Scripts or CI that assume main then fail on git push origin main or git checkout main in fresh temp repos. Set it explicitly with git init -b main, or git config --global init.defaultBranch main, and read the current branch with git symbolic-ref --short HEAD instead of assuming it. Check: git --version; git config --get init.defaultBranch || echo unset. Comment your git version and default.