How to add git remote


add a Git Remote

$ git remote add [<options>] <name> <url>
  • example
$ git remote add origin https://github.com/OWNER/REPOSITORY.git

list remote connection

$ git remote -v  
...
origin	https://github.com/OWNER/REPOSITORY.git (fetch)
origin	https://github.com/OWNER/REPOSITORY.git (push)

if error

$ git remote add origin https://github.com/OWNER/REPOSITORY.git
> 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