gpt4 book ai didi

git - 禁止关于默认初始分支名称的 git 警告

转载 作者:行者123 更新时间:2023-12-04 12:09:38 27 4
gpt4 key购买 nike

创建新的 Git 存储库时,您现在会看到以下消息:

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>
有没有办法在不更改我的全局 git 配置的情况下抑制此消息?

最佳答案

好像你可以做到

git init --quiet   # or git init -q
我不确定会抑制哪些其他信息,但它会抑制此通知。
然而,这确实意味着初始分支名称没有明确定义(他们可能会稍后将其更改为例如 main),因此最好这样做:
git init --initial-branch=master    # or git init -b master

关于git - 禁止关于默认初始分支名称的 git 警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66483436/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com