Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Suppress git warning about default initial branch name

Tags:

git

When creating a new Git repo you now see this message:

Initialized empty Git repository in /private/var/folders/g5/8twmk1xj481_6btvppyw5j4h0000gp/T/.tmpNYVg6H/.git/
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>

Is there a way to suppress this message without changing my global git config?

like image 727
Timmmm Avatar asked Mar 04 '21 21:03

Timmmm


1 Answers

It seems like you can do

git init --quiet   # or git init -q

I'm not exactly sure what other information that will suppress but it suppresses this notice.

However it does mean that the initial branch name is not well defined (they might change it to e.g. main later), so it's probably best to do this:

git init --initial-branch=master    # or git init -b master
like image 177
Timmmm Avatar answered Sep 22 '22 01:09

Timmmm