git remote add command takes two arguments:
- A remote name, for example,
- A remote URL, for example,
$ git remote add origin https://hostname/user/repo.git # Set a new remote $ git remote -v # Verify new remote > origin https://hostname/user/repo.git (fetch) > origin https://hostname/user/repo.git (push)
Not sure which URL to use? Check out "Which remote URL should I use?"
You may encounter these errors when trying to add a remote.
name already exists
This error means you've tried to add a remote with a name that already exists in your local repository:
$ git remote add origin https://hostname/octocat/Spoon-Knife > fatal: remote origin already exists.
To fix this, you can
- Use a different name for the new remote
- Rename the existing remote
- Delete the existing remote