Adding a remote

To add a new remote, use the git remote add command on the terminal, in the directory your repository is stored at.

In this article

Did this doc help you?

Help us make these docs great!

All GitHub docs are open source. See something that's wrong or unclear? Submit a pull request.

Make a contribution

Or, learn how to contribute.

The git remote add command takes two arguments:

  • A remote name, for example, origin
  • A remote URL, for example, https://github.com/user/repo.git

For example:

$ git remote add origin https://github.com/user/repo.git
# Set a new remote

$ git remote -v
# Verify new remote
> origin  https://github.com/user/repo.git (fetch)
> origin  https://github.com/user/repo.git (push)

Not sure which URL to use? Check out "Which remote URL should I use?"

Troubleshooting

You may encounter these errors when trying to add a remote.

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://github.com/octocat/Spoon-Knife
> fatal: remote origin already exists.

To fix this, you can

Further reading

Did this doc help you?

Help us make these docs great!

All GitHub docs are open source. See something that's wrong or unclear? Submit a pull request.

Make a contribution

Or, learn how to contribute.