* git branch behavior after git init needs fixing
@ 2026-02-09 9:43 Ryan Johnson
2026-02-09 14:54 ` Ben Knoble
0 siblings, 1 reply; 4+ messages in thread
From: Ryan Johnson @ 2026-02-09 9:43 UTC (permalink / raw)
To: git@vger.kernel.org
Immediately after running `git init`, Git's `git branch` output is empty.
This is problematic because this implies that there is no default branch. I am told that there is a subtle distinction between an already-created branch and a "promise" to create a branch upon git init. The "promise" of a branch is not exposed, when it should be in the `git branch`command.
Hiding the default branch name from git branch is inconsistent with the information reported by other commands like `git status` and clashes with the availability of branch operations. `git status` reports that the repository is "On branch master". A typical user will need to rename their branch from master to main to conform with modern standards, so having no branch shown is confusing and quite frankly wrong. In the interest of fixing stupid UX design, make `git branch`produce the expected output, regardless of the literal internal workings of git.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: git branch behavior after git init needs fixing
2026-02-09 9:43 git branch behavior after git init needs fixing Ryan Johnson
@ 2026-02-09 14:54 ` Ben Knoble
2026-02-09 17:08 ` Junio C Hamano
0 siblings, 1 reply; 4+ messages in thread
From: Ben Knoble @ 2026-02-09 14:54 UTC (permalink / raw)
To: Ryan Johnson; +Cc: git
> Le 9 févr. 2026 à 04:43, Ryan Johnson <ryan.johnson.code@gmail.com> a écrit :
>
> Immediately after running `git init`, Git's `git branch` output is empty.
>
> This is problematic because this implies that there is no default branch. I am told that there is a subtle distinction between an already-created branch and a "promise" to create a branch upon git init. The "promise" of a branch is not exposed, when it should be in the `git branch`command.
I believe this is called an « unborn » or « orphan » branch (see « git help switch » for example).
> Hiding the default branch name from git branch is inconsistent with the information reported by other commands like `git status` and clashes with the availability of branch operations. `git status` reports that the repository is "On branch master".
[no comment from me]
> A typical user will need to rename their branch from master to main to conform with modern standards, so having no branch shown is confusing and quite frankly wrong.
You are probably looking for init.defaultBranch and the 3.0 breaking changes plan (which will make main the default).
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: git branch behavior after git init needs fixing
2026-02-09 14:54 ` Ben Knoble
@ 2026-02-09 17:08 ` Junio C Hamano
2026-02-09 22:38 ` Junio C Hamano
0 siblings, 1 reply; 4+ messages in thread
From: Junio C Hamano @ 2026-02-09 17:08 UTC (permalink / raw)
To: Ben Knoble; +Cc: Ryan Johnson, git
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.
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: git branch behavior after git init needs fixing
2026-02-09 17:08 ` Junio C Hamano
@ 2026-02-09 22:38 ` Junio C Hamano
0 siblings, 0 replies; 4+ messages in thread
From: Junio C Hamano @ 2026-02-09 22:38 UTC (permalink / raw)
To: Ben Knoble; +Cc: Ryan Johnson, git
Junio C Hamano <gitster@pobox.com> writes:
> 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/
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-02-09 22:38 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-09 9:43 git branch behavior after git init needs fixing Ryan Johnson
2026-02-09 14:54 ` Ben Knoble
2026-02-09 17:08 ` Junio C Hamano
2026-02-09 22:38 ` Junio C Hamano
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox