version control
git remotes
git repository
git commands
software development

List of remotes for a Git repository?

Master System Design with Codemia

Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.

Introduction

To see the remotes configured for a Git repository, use git remote or git remote -v. The first shows remote names, and the second shows the fetch and push URLs associated with those names.

The Fastest Commands

To list just the remote names:

bash
git remote

Typical output:

text
origin
upstream

To see the URLs too:

bash
git remote -v

Typical output:

text
1origin   [email protected]:me/project.git (fetch)
2origin   [email protected]:me/project.git (push)
3upstream [email protected]:org/project.git (fetch)
4upstream [email protected]:org/project.git (push)

For most everyday work, git remote -v is the practical answer.

What a Remote Actually Is

A remote is a named reference to another Git repository. The name is local to your repository clone.

Common conventions:

  • 'origin for the main remote you cloned from'
  • 'upstream for the original project when you work from a fork'
  • 'backup or other custom names for mirrors or secondary destinations'

Remote names are not magical. They are just labels stored in the local repository config.

Show More Detail About One Remote

If you want more than the URL, inspect one remote directly:

bash
git remote show origin

This can display:

  • fetch URL
  • push URL
  • tracked branches
  • which remote branch your local branches track
  • whether stale references exist

This is useful when the question is not just "what remotes exist" but "how is this remote wired into my branch workflow."

Read the URLs Explicitly

If you only want a single remote's URL without the extra formatting:

bash
git remote get-url origin

And if you need the push URL specifically:

bash
git remote get-url --push origin

This is handy in scripts, CI, or when checking whether fetch and push URLs differ.

Remotes Live in Git Config

Under the hood, remotes are stored in Git configuration.

You can inspect them directly:

bash
git config --get-regexp '^remote\\.'

That may produce output like:

text
remote.origin.url [email protected]:me/project.git
remote.origin.fetch +refs/heads/*:refs/remotes/origin/*

This is useful when you need to understand the actual config rather than the friendly command output.

Add, Rename, and Remove Remotes

Listing remotes is often the first step before changing them.

Add a new one:

bash
git remote add upstream [email protected]:org/project.git

Rename one:

bash
git remote rename upstream source

Remove one:

bash
git remote remove backup

These commands operate on the local repository only. They do not delete the remote server itself.

When git remote Shows Nothing

If git remote returns no output, that usually means:

  • the repository has no remotes configured
  • it was initialized with git init and no remote was added
  • a remote was removed earlier

That is not an error by itself. Git works fine without remotes; it just means the repository is not currently linked to any external repository locations.

Common Pitfalls

  • Using git remote and expecting URLs when it only shows names.
  • Assuming origin is special beyond being a common default name.
  • Forgetting that fetch and push URLs can differ.
  • Looking only at branch tracking and not verifying the actual remote URL.
  • Thinking remote removal deletes the hosted repository rather than only the local reference.

Summary

  • Use git remote to list remote names.
  • Use git remote -v to list names plus fetch and push URLs.
  • Use git remote show <name> for more detailed remote information.
  • Use git remote get-url <name> when you need one exact URL.
  • Remotes are local configuration entries, not special built-in server objects.

Course illustration
Course illustration

All Rights Reserved.