List of remotes for a Git repository?
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.
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:
Typical output:
To see the URLs too:
Typical output:
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:
- '
originfor the main remote you cloned from' - '
upstreamfor the original project when you work from a fork' - '
backupor 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:
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:
And if you need the push URL specifically:
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:
That may produce output like:
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:
Rename one:
Remove one:
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 initand 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 remoteand expecting URLs when it only shows names. - Assuming
originis 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 remoteto list remote names. - Use
git remote -vto 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.
Related reading
- List submodules in a Git repository
- list tags contained by a branch
- Locking binary files using git version control system
- Logout and login as another user git bash
- Maintain git repo inside another git repo
- Make an existing Git branch track a remote branch?
- Make 'git diff' ignore M
- Make .gitignore ignore everything except a few files
.png&w=3840&q=75)
Tackling System Design Interview Problems
A short course that equips you with the skills to approach system design interviews methodically.
Start the free courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.