Re: git branch behavior after git init needs fixing
From: Junio C Hamano <hidden>
Date: 2026-02-09 22:38:06
Junio C Hamano [off-list ref] writes:
Ben Knoble [off-list ref] writes:quoted
You are probably looking for init.defaultBranch and the 3.0 breaking changes plan (which will make main the default).In other words, run $ git config --global init.defaultbranch main just once to live in the future? That sounds like a sensible suggestion to me.
And that is excatly what "git init" gives our users already, until s/he sees it sufficiently often and declines to see it anymore, at which point they are on their own ;-) After temporarily disabling init.defaultBranch setting in my configuration files (and I left advice.defaultBranchName setting to the default), here is what I (or anybody) would get. $ git init hint: Using 'master' as the name for the initial branch. This default branch name hint: will change to "main" in Git 3.0. To configure the initial branch name hint: to use in all of your new repositories, which will suppress this warning, hint: call: hint: hint: git config --global init.defaultBranch <name> hint: hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and hint: 'development'. The just-created branch can be renamed via this command: hint: hint: git branch -m <name> hint: hint: Disable this message with "git config set advice.defaultBranchName false" Initialized empty Git repository in /var/tmp/x/.git/