git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: git branch behavior after git init needs fixing

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 9, 2026, 22:38 UTC
Message-ID
<xmqqms1h35mc.fsf@gitster.g>
In-Reply-To
<xmqqjywl6e0w.fsf@gitster.g>
Junio C Hamano <gitster@pobox.com> writes:
Show 11 quoted lines
> Ben Knoble <ben.knoble@gmail.com> writes:
>
>> 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/

Previous: Junio C Hamano
Message 4 of 4 in “git branch behavior after git init needs fixing”
  1. Ryan JohnsonFeb 9, 2026
  2. Ben KnobleFeb 9, 2026
  3. Junio C HamanoFeb 9, 2026
  4. Junio C HamanoFeb 9, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.