简体   繁体   English

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

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

I am absolutly new in GIT and GitHub and I have the following problem trying to link my local repository to a GitHub account 我对GIT和GitHub绝对陌生,尝试将我的本地存储库链接到GitHub帐户时遇到以下问题

I do: 我做:

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'

where https://github.com/AndreaNobili/recipes.git is the https link provided by GitHub for this repository. 其中https://github.com/AndreaNobili/recipes.git是GitHub为该存储库提供的https链接。

Why I obtain this error message? 为什么我收到此错误消息? What means No such remote 'origin' ? 什么意味着没有这样的远程“起源” How can I fix this issue? 如何解决此问题?

The command you are using is not adding a remote but setting the URL of an existing remote . 您使用的命令不是添加远程,而是设置现有远程的URL The command you are looking for is 您正在寻找的命令是

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

set-url can be used if you want to change an URL or fix a typo: 如果您要更改URL或修正拼写错误,可以使用set-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

As an extention to this, you could use 作为扩展,您可以使用

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

This tracks the master branch only 这仅跟踪主分支

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

This tracks the different-oil branch 这跟踪不同的油分支

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM