如何禁用关于git初始分支名称的git消息
我知道 Microsoft 最近更改了 github 存储库中的初始分支名称,但是现在当我在计算机上运行“git init”时,我收到一条黄色警报消息,说明我可以将初始分支名称更改为“master”。. 一些别的名字。这让我感到不舒服,并且不能让我安心工作,因为我看到一条黄色消息,默认情况下我会阅读,因为它吸引了我的注意力并分散了我的注意力。
现在如何禁用该消息?
我丝毫没有改变分支名称的默认设置的意图,因为说实话这有点愚蠢。
回答
较新版本的 Git 在启动新存储库时确实会产生警告:
$ 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/
现在如何禁用该消息?
它在那里说:
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>
因此,如果您想继续使用 master:
git config --global init.defaultBranch master
顺便提一句,
我了解微软最近更改了 github 存储库中的初始分支名称
微软强大而强大,但它不拥有 Git。