{"thread":{"id":"64953","subject":"git branch behavior after git init needs fixing","startedAt":"2026-02-09T09:43:09Z","lastAt":"2026-02-09T22:38:06Z","messageCount":4,"participants":["Ryan Johnson","Ben Knoble","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"535510","messageId":"DS0PR03MB72900848B03D2B87A6846DCAA365A@DS0PR03MB7290.namprd03.prod.outlook.com","threadId":"64953","inReplyTo":null,"subject":"git branch behavior after git init needs fixing","fromName":"Ryan Johnson","fromEmail":"ryan.johnson.code@gmail.com","sentAt":"2026-02-09T09:43:07Z","receivedAt":"2026-02-09T09:43:09Z","isPatch":false,"sender":{"key":"ryan.johnson.code@gmail.com","avatar":null},"body":"Immediately after running `git init`, Git's `git branch` output is empty.\n\nThis 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.\n\nHiding 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.\n"},{"id":"535542","messageId":"D1CA4E13-B279-4931-81EF-364169564612@gmail.com","threadId":"64953","inReplyTo":"DS0PR03MB72900848B03D2B87A6846DCAA365A@DS0PR03MB7290.namprd03.prod.outlook.com","subject":"Re: git branch behavior after git init needs fixing","fromName":"Ben Knoble","fromEmail":"ben.knoble@gmail.com","sentAt":"2026-02-09T14:54:25Z","receivedAt":"2026-02-09T14:54:37Z","isPatch":false,"sender":{"key":"ben.knoble@gmail.com","avatar":"https://avatars.githubusercontent.com/u/22802209?v=4"},"body":"\n> Le 9 févr. 2026 à 04:43, Ryan Johnson <ryan.johnson.code@gmail.com> a écrit :\n> \n> ﻿Immediately after running `git init`, Git's `git branch` output is empty.\n> \n> 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.\n\nI believe this is called an « unborn » or « orphan » branch (see « git help switch » for example).\n\n> 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\".\n\n[no comment from me]\n\n> 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.\n\nYou are probably looking for init.defaultBranch and the 3.0 breaking changes plan (which will make main the default)."},{"id":"535571","messageId":"xmqqjywl6e0w.fsf@gitster.g","threadId":"64953","inReplyTo":"D1CA4E13-B279-4931-81EF-364169564612@gmail.com","subject":"Re: git branch behavior after git init needs fixing","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-02-09T17:08:15Z","receivedAt":"2026-02-09T17:08:18Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ben Knoble <ben.knoble@gmail.com> writes:\n\n> You are probably looking for init.defaultBranch and the 3.0\n> breaking changes plan (which will make main the default).\n\nIn other words, run\n\n    $ git config --global init.defaultbranch main\n\njust once to live in the future?  That sounds like a sensible\nsuggestion to me.\n\n"},{"id":"535615","messageId":"xmqqms1h35mc.fsf@gitster.g","threadId":"64953","inReplyTo":"xmqqjywl6e0w.fsf@gitster.g","subject":"Re: git branch behavior after git init needs fixing","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-02-09T22:38:03Z","receivedAt":"2026-02-09T22:38:06Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> Ben Knoble <ben.knoble@gmail.com> writes:\n>\n>> You are probably looking for init.defaultBranch and the 3.0\n>> breaking changes plan (which will make main the default).\n>\n> In other words, run\n>\n>     $ git config --global init.defaultbranch main\n>\n> just once to live in the future?  That sounds like a sensible\n> suggestion to me.\n\nAnd that is excatly what \"git init\" gives our users already, until\ns/he sees it sufficiently often and declines to see it anymore, at\nwhich point they are on their own ;-)\n\nAfter temporarily disabling init.defaultBranch setting in my\nconfiguration files (and I left advice.defaultBranchName setting to\nthe default), here is what I (or anybody) would get.\n\n$ git init\nhint: Using 'master' as the name for the initial branch. This default branch name\nhint: will change to \"main\" in Git 3.0. To configure the initial branch name\nhint: to use in all of your new repositories, which will suppress this warning,\nhint: call:\nhint:\nhint: \tgit config --global init.defaultBranch <name>\nhint:\nhint: Names commonly chosen instead of 'master' are 'main', 'trunk' and\nhint: 'development'. The just-created branch can be renamed via this command:\nhint:\nhint: \tgit branch -m <name>\nhint:\nhint: Disable this message with \"git config set advice.defaultBranchName false\"\nInitialized empty Git repository in /var/tmp/x/.git/\n"}]}