Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to disable git message about git initial branch name

Tags:

git

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.

like image 428
al3x Avatar asked Dec 31 '20 18:12

al3x


People also ask

What would you like git to name the initial branch after git init?

While “master” is the default name for a starting branch when you run git init which is the only reason it's widely used, “origin” is the default name for a remote when you run git clone. If you run git clone -o booyah instead, then you will have booyah/master as your default remote branch.

Is git changing default branch name?

Phase 2 (Self-managed): We will change the default branch name from master to main for self-managed GitLab as part for our next major release 14.0, shipping on June 22, 2021. Any project created in GitLab post 14.0 will use the new default. This does not affect existing projects.


1 Answers

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.

like image 144
Arkadiusz Drabczyk Avatar answered Oct 05 '22 21:10

Arkadiusz Drabczyk