为什么我不能将此远程 GitHub 存储库作为远程存储库添加到我的本地 GIT 存储库?

Why I can't add this remote GitHub repository to my local GIT repository as remote?

我绝对是 GIT 和 GitHub 的新手,我在尝试将我的本地存储库 link 到 GitHub 帐户时遇到以下问题

我愿意:

Andrea@Andrea-PC MINGW64 ~/Documents/WS_vari/version-control/recipes (master)
$ git remote set-url origin https://github.com/AndreaNobili/recipes.git
fatal: No such remote 'origin'

其中 https://github.com/AndreaNobili/recipes.git 是 GitHub 为此存储库提供的 https link。

为什么我会收到此错误消息? 没有这样的遥控器'origin'是什么意思?我该如何解决这个问题?

您使用的命令不是添加遥控器,而是设置现有遥控器URL。您正在查找的命令是

git remote add origin https://github.com/AndreaNobili/recipes.git

set-url 可用于更改 URL 或修正拼写错误:

# Note the typo in the URL:
git remote add origin https://gmail.com/AndreaNobili/recipes.git
# This command fixes the typo:
git remote set-url origin https://github.com/AndreaNobili/recipes.git

作为对此的扩展,您可以使用

git remote add --track master origin github.com/AndreaNobili/recipes.git
git remote add --master origin github.com/AndreaNobili/recipes.git

这只跟踪 master 分支

git remote add --track different-oil origin github.com/AndreaNobili/recipes.git

这跟踪不同的油分支