How to list Git remotes

Greg Foster
Greg Foster
Graphite software engineer

A Git remote refers to a version of a repository that is hosted on the internet, or on a network somewhere outside your local machine. Remotes make it possible to collaborate with others by allowing multiple developers to push to and pull from the repository. Typically, a remote is a repository on a service like GitHub, GitLab, or Bitbucket, or on a private server.

This guide will explain what Git remotes are, how to list them, and provide some context on their usage.

Before you push your changes or fetch updates from the codebase, it's useful to check which remotes are configured. This helps ensure that you are interacting with the correct repository and can serve as a quick check to make sure you have configured your remotes properly.

To see which remotes are currently configured for your repository, you can use the git remote command. This command lists the names of all remotes:

Terminal
git remote

When run, this might output something like:

Terminal
origin
upstream
  • origin: This is the default name Git gives to the remote from which you cloned the repository.
  • upstream: Often used to refer to the original repository when yours is a fork of another project.

To see more detailed information about these remotes, including their URLs, you can use:

Terminal
git remote -v

This command outputs the remote names along with the URLs associated with the fetch and push operations:

Terminal
origin https://github.com/user/repo.git (fetch)
origin https://github.com/user/repo.git (push)
upstream https://github.com/original/repo.git (fetch)
upstream https://github.com/original/repo.git (push)

For even more detailed information about a specific remote, use:

Terminal
git remote show <remote-name>

For example:

Terminal
git remote show origin

This command will give detailed information about the remote called "origin," including its URL, the branches it tracks, and more.

Terminal
* remote origin
Fetch URL: https://github.com/user/repo.git
Push URL: https://github.com/user/repo.git
HEAD branch: main
Remote branches:
main tracked
develop tracked
Local branch configured for 'git pull':
main merges with remote main
develop merges with remote develop
Local ref configured for 'git push':
main pushes to main (up to date)
develop pushes to develop (up to date)

Beyond listing remotes, you may need to manage them by adding new ones or changing existing ones.

In open-source projects, it's common to fork a repository to make changes independently. After forking, developers typically add the original repository as an additional remote (often named upstream) to their local clone. This setup allows them to fetch the latest updates from the original repository and keep their fork up to date. It's also necessary for submitting pull requests that merge their changes back into the main project.

If you want to add a new remote, run:

Terminal
git remote add <remote-name> <remote-url>

For example:

Terminal
git remote add upstream https://github.com/original/repo.git

To change the URL of an existing remote, for instance if the repository has moved, run:

Terminal
git remote set-url origin https://github.com/newuser/repo.git

To remove a remote, for example if it was deleted, you can run:

Terminal
git remote remove <remote-name>

If we were to remove the upstream we added in the last example, we'd run:

Terminal
git remote remove upstream

For further reading, see the official Git documentation.

Stay unblocked. Ship faster.
Experience the new developer workflow - create, review, and merge code continuously. Get started with one command.
Get started

Give your PR workflow
an upgrade today

Stack easier | Ship smaller | Review quicker

Or install our CLI.
Product Screenshot 1
Product Screenshot 2