git config --global init.defaultBranch main

Category: Git - Core

git config --global init.defaultBranch main

Default new repositories to main

Sets the branch name that git init creates, replacing the historical master default. New repositories start on main instead of needing a rename later. It does not change existing repositories.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.