How to retrieve the remote URL in Git

Kenny DuMez
Kenny DuMez
Graphite software engineer


Note

This guide explains this concept in vanilla Git. For Graphite documentation, see our CLI docs.


A remote URL in Git refers to the network path of your Git repository that is stored on a remote server, which can be accessed over the internet or a local network. This guide will walk you through the steps to find the remote URL of your Git repo, explaining the commands and providing tips to effectively manage your remotes.

A remote in Git is a common repository that all team members use to exchange their changes. In most cases, the remote repository is on a server on the internet or on your local network. The default remote is usually named origin, but Git supports having multiple remotes for a single local repository.

Start by opening your terminal (Linux or macOS) or command prompt/Git Bash (Windows) and navigate to your local Git repository using the cd command.

To see a list of all remotes and their associated URLs, use the following command:

Terminal
git remote -v

This command displays all the remotes linked to your repository. The -v flag stands for "verbose", which tells Git to also show the URLs associated with the remote names. Typically, this will list both fetch and push URLs for each remote. The fetch URL is used by Git to download content from the remote repository, whereas the push URL is used to upload content to it. This dual listing helps you understand where your changes are being fetched from and where they are being pushed to.

The output from git remote -v might look something like this:

Terminal
origin https://github.com/username/repository.git (fetch)
origin https://github.com/username/repository.git (push)
upstream https://github.com/anotheruser/repository.git (fetch)
upstream https://github.com/anotheruser/repository.git (push)
  • origin/upstream: These are the names of the remotes. origin is usually the default remote given to the server from which the repository was first cloned. upstream is often used to refer to the original repository when your repository is a fork of another.
  • URLs: These are the paths that Git uses to fetch from and push to the remote. They can be HTTPS URLs or SSH addresses.
  • (fetch)/(push): Indicates whether the URL is used for fetching or pushing.

If you need more information about a specific remote, use the git remote show command followed by the name of the remote:

Terminal
git remote show origin

This command will provide detailed information about the origin remote, including its fetch and push URLs, the tracking branches, and more.

If you find that the remote URL needs to be updated (for instance, if the repository has moved), you can change it using the git remote set-url command:

Terminal
git remote set-url origin new-url

Replace new-url with the actual URL you want to set.

For further reading on Git remotes, see the official Git documentation.

Git inspired
Graphite's CLI and VS Code extension make working with Git effortless.
Learn more

Graphite
Git stacked on GitHub

Stacked pull requests are easier to read, easier to write, and easier to manage.
Teams that stack ship better software, faster.

Or install our CLI.
Product Screenshot 1
Product Screenshot 2