AndreaNobili AndreaNobili - 3 months ago 19
Git Question

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

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.

Why I obtain this error message? What means No such remote 'origin'? How can I fix this issue?

Answer

The command you are using is not adding a remote but setting the URL of an existing remote. 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:

# 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