0
0
GitHow-ToBeginner · 3 min read

How to Use git remote -v to View Remote Repositories

Use git remote -v to list all remote repositories linked to your local Git project along with their fetch and push URLs. This command helps you see where your code is pushed or pulled from.
📐

Syntax

The command git remote -v shows the remote repositories for your Git project. Here:

  • git remote manages remote connections.
  • -v stands for verbose, showing URLs for fetch and push.
bash
git remote -v
💻

Example

This example shows how git remote -v lists remotes with their URLs for fetch and push operations.

bash
$ git remote -v
origin  https://github.com/user/repo.git (fetch)
origin  https://github.com/user/repo.git (push)
Output
origin https://github.com/user/repo.git (fetch) origin https://github.com/user/repo.git (push)
⚠️

Common Pitfalls

Common mistakes include:

  • Running git remote without -v shows only remote names, not URLs.
  • Confusing fetch and push URLs if they differ.
  • Assuming remotes exist before adding them.
bash
$ git remote
origin

# This shows only names, not URLs

# Correct usage:
git remote -v
Output
origin
📊

Quick Reference

CommandDescription
git remote -vList all remotes with URLs for fetch and push
git remoteList remote names only
git remote add Add a new remote repository
git remote remove Remove a remote repository

Key Takeaways

Use git remote -v to see remote names and their URLs for fetch and push.
Without -v, git remote shows only remote names, not URLs.
Check both fetch and push URLs as they can be different.
Add remotes before using git remote -v to see them listed.