21

I understand Microsoft recently changed the initial branch name in the github repositories, but now when I run "git init" on my computer I get a yellow alert message explaining that I can change the initial branch name to "master ". . some other name. And that makes me uncomfortable and does not let me work at ease because I see a yellow message and by default I read because it catches my attention and that distracts me.

Now how to disable that message?

I don't have the slightest intention of changing the default setting of the branch name because to be honest that's kind of silly.

7
  • 7
    @U.Windl: many would agree but SO is not a place for such discussions Commented Dec 31, 2020 at 18:40
  • 3
    @ArkadiuszDrabczyk I agree Commented Dec 31, 2020 at 18:44
  • How does what Microsoft does with their branch names affect what happens when you run git init? Commented Dec 31, 2020 at 19:01
  • 1
    @mkrieger1: Microsoft is almighty. Seriously, newer versions of git ineed produce a waring: hint: Using 'master' as the name for the initial branch. This default branch name hint: is subject to change. To configure the initial branch name to use in all hint: of your new repositories, which will suppress this warning, call: Commented Dec 31, 2020 at 19:04
  • 12
    @ArkadiuszDrabczyk if SO is not the place where we talk about politics, why git warns such hint within ? git itself introduces such controversial debate into the open source world, It's git who should be ashamed of itself, not us. Commented Jan 31, 2022 at 5:05

2 Answers 2

36

Newer versions of Git indeed produce a warning when initting a new repository:

$ git init
warning: templates not found in /home/ja/share/git-core/templates
hint: Using 'master' as the name for the initial branch. This default branch name
hint: is subject to change. To configure the initial branch name to use in all
hint: of your new repositories, which will suppress this warning, 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>
Initialized empty Git repository in /tmp/new/.git/

Now how to disable that message?

It says right there:

To configure the initial branch name to use in all
hint: of your new repositories, which will suppress this warning, call:
hint:
hint:   git config --global init.defaultBranch <name>

So if you want to keep using master:

git config --global init.defaultBranch master

BTW,

I understand Microsoft recently changed the initial branch name in the github repositories

Microsoft is big and powerful but it doesn't own Git.

Sign up to request clarification or add additional context in comments.

1 Comment

I initially thought about it, but I ran "git config --global init.defaultBranch <master>" (my error), it's just that sometimes you are so into something and overlook those errors, sorry
8

Specify the default branch in the init command without changing the configuration

git -c init.defaultBranch=master init

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.