How to Manage Remote Repositories in Git (git remote)

git remote manages the set of remote repository URLs your local repository knows about, most commonly a single "origin".

Published September 28, 2026

git remote lists and manages the remote repositories your local repo knows about, such as origin on GitHub.

How it works

Each remote is a name plus a URL. You can have several, for example origin and upstream when working with forks.

Use -v to see URLs.

Try it

git remote -v
origin git@github.com:me/app.git (fetch)
origin git@github.com:me/app.git (push)

Practical examples

Add a remote

git remote add upstream https://github.com/org/app.git

Change a URL

git remote set-url origin git@github.com:me/new.git

Remove

git remote remove upstream

Rename

git remote rename origin github

Common mistakes

  • Pushing to the wrong remote.
  • Forgetting to fetch the upstream of a fork.
  • Leaving credentials in the URL.

Key takeaways

  • remotes = named URLs.
  • origin is the default name.
  • Forks use origin plus upstream.

FAQ

How do I switch HTTPS to SSH?

git remote set-url origin <ssh-url>.

How do I see more details?

git remote show origin.

More Git articles