gpt4 book ai didi

Github直接push到main

转载 作者:行者123 更新时间:2023-12-03 20:00:55 25 4
gpt4 key购买 nike

随着最近master的变化至 main在 Github 中,看来我需要先推送到 master然后与 main merge .当我尝试使用 --remote-upstream 推送时至 main我收到一个错误:error: src refspec main does not match any .
在带有 OMZ 的 iterm2 上,当我第一次运行时 git init我看到master在路径中。
如何直接推送到主而不是先推送到主?

最佳答案

如果我没记错的话,在 Git 版本 2.28.0 中,您可以使用命令 git init -b为了设置您的默认分支。
例如,使用 main 创建一个新的存储库分支作为默认分支。

git init -b main
如果您想输入更长的名称:
git init --initial-branch=main
您甚至可以全局设置它。
git config --global init.defaultBranch main
作为替代方案,在创建新存储库时,您可以执行 git clone到您的系统。默认分支将相应调整。

关于 git init -b命令,取自 Git 的文档:

Use the specified name for the initial branch in the newly created repository. If not specified, fall back to the default name (currently master, but this is subject to change in the future; the name can be customized via the init.defaultBranch configuration variable).


阅读更多 here .

另一种选择,只需将默认分支名称保留为 master在您的远程存储库中。

关于Github直接push到main,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66621725/

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