After you've connected your local repository to one or more remote repositories, or when you clone a project that already has remote connections, you'll often need to check which remotes are configured and where they point. Git provides a simple command for this purpose.
To see a list of the shortnames assigned to the remote repositories your local repository knows about, you can use the git remote
command:
$ git remote
origin
This command lists the shortnames of each remote handle you’ve specified. If you cloned a repository, you will at least see origin
. This is the default name Git gives to the server you cloned from. If you added remotes manually using git remote add
, their shortnames will also appear here.
While knowing the shortnames is useful, it doesn't tell you where these remotes are located. To see the URLs associated with each shortname, you can add the -v
(or --verbose
) option to the git remote
command:
$ git remote -v
origin https://github.com/user/project.git (fetch)
origin https://github.com/user/project.git (push)
upstream https://github.com/original-maintainer/project.git (fetch)
upstream https://github.com/original-maintainer/project.git (push)
This output provides more detail. Each remote connection is listed twice: once for fetching (downloading data) and once for pushing (uploading data).
origin
, upstream
).git@github.com:user/project.git
), or another protocol.git fetch
or git pull
to get changes from the remote.git push
to send your changes to the remote.In many common scenarios, the fetch and push URLs for a given remote shortname will be identical, as shown for both origin
and upstream
in the example above. However, Git allows them to be different, which can be useful in specific setups (for example, read-only access for fetching, write access for pushing to a different location, although this is less common for beginners).
Running git remote -v
is a fundamental step when working with remotes. It helps you:
git fetch origin
or git push upstream my-feature-branch
.Knowing how to view your configured remotes is essential for managing your connections and collaborating effectively. It provides clarity on where your local project is connected and allows you to interact confidently with remote repositories.
© 2025 ApX Machine Learning