Git Remote – List repositories
Git Remote is used to manage the list of remote repositories configured in a local Git repository. To display the remote repository names, use git remote. To display both remote names and their fetch or push URLs, use git remote -v.
A remote in Git is a saved connection to another repository. It may point to an online repository such as GitHub, GitLab, or Bitbucket, or to another repository path on the same system. The git remote command lists the remotes configured for the current local repository; it does not list every repository in your hosting account.
Git remote command syntax to list configured repositories
The syntax of git command to list repositories is
git remote [-v]
Without -v, Git prints only the remote names. With -v, Git prints the remote names, URLs, and whether each URL is used for fetch or push operations.
Display Git remote repository names with git remote
In the following example, we shall display repositories list.
Run the following command.
git remote
The command prints the names of remote repositories configured in the current local Git repository.
$ git remote
origin
spark
In this output, origin and spark are remote names. They are local aliases used by Git commands such as git fetch, git pull, and git push.
Display Git remote repository URLs with git remote -v
Let us use the verbose option with the git remote command.
$ git remote -v
origin https://github.com/tutorialkart/git-tutorial.git (fetch)
origin https://github.com/tutorialkart/git-tutorial.git (push)
spark https://github.com/apache/spark (fetch)
spark https://github.com/apache/spark (push)
Not only the name of remotes are displayed, but also the url and the operations it supports.
The same remote may appear twice because Git can store separate URLs for fetch and push. In many repositories, both URLs are the same. In some workflows, the fetch URL and push URL may be different, for example when reading from an upstream project but pushing to your own fork.
Show the URL of one Git remote repository
If you want the URL for a specific remote, use git remote get-url followed by the remote name.
git remote get-url <remote-name>
For example, the following command prints the URL configured for origin.
git remote get-url origin
https://github.com/tutorialkart/git-tutorial.git
To check only the push URL for a remote, use the --push option.
git remote get-url --push origin
Show detailed information for a Git remote origin
The git remote show command gives more details about a remote, including the remote URL, HEAD branch, remote branches, and local branch tracking information.
git remote show origin
* remote origin
Fetch URL: https://github.com/tutorialkart/git-tutorial.git
Push URL: https://github.com/tutorialkart/git-tutorial.git
HEAD branch: main
Remote branches:
main tracked
Local branch configured for 'git pull':
main merges with remote main
Local ref configured for 'git push':
main pushes to main
This command is useful when you need more than the remote URL. It helps confirm which branch is tracked and how git pull and git push are configured for the local repository.
List remote branches instead of remote repositories
Listing remote repositories and listing remote branches are different tasks. The git remote command lists remote names such as origin. To list remote-tracking branches, use git branch -r.
git branch -r
origin/main
origin/develop
spark/master
To list both local and remote-tracking branches, use git branch -a.
git branch -a
If the branch list looks outdated, fetch the latest remote references first.
git fetch --all --prune
The --prune option removes stale remote-tracking references for branches that no longer exist on the remote.
List remote branch references directly from the remote repository
To inspect branch references from a remote repository without relying only on local remote-tracking refs, use git ls-remote.
git ls-remote --heads origin
1a2b3c4d5e6f7890 refs/heads/main
2b3c4d5e6f7890a1 refs/heads/develop
This is useful when you need to check what branch heads exist on the remote server. The exact commit hashes and branch names will depend on your repository.
Common Git commands related to listing remotes
| Command | What it lists or shows | Typical use |
|---|---|---|
git remote | Remote names only | Check whether the repository has remotes such as origin. |
git remote -v | Remote names with fetch and push URLs | Verify the URL before fetch, pull, or push. |
git remote get-url origin | URL of one remote | Copy or inspect the configured URL for origin. |
git remote show origin | Detailed remote and tracking information | Check tracked branches and pull or push configuration. |
git branch -r | Remote-tracking branches | See branches known locally from remotes. |
git ls-remote --heads origin | Branch heads available on the remote | Inspect remote branch refs directly. |
When git remote does not show any repository
If git remote prints nothing, the current local repository has no remote configured. Add a remote repository using git remote add.
git remote add origin https://github.com/tutorialkart/git-tutorial.git
If Git says the current directory is not a Git repository, move into the correct project folder or initialize a repository first.
fatal: not a git repository (or any of the parent directories): .git
To confirm that you are inside a Git working tree, run the following command.
git status
Git remote list troubleshooting checklist
- Run
git statusfirst ifgit remotereturns an error about not being in a Git repository. - Use
git remotewhen you need only remote names such asoriginorupstream. - Use
git remote -vwhen you need the fetch and push URLs. - Use
git remote get-url originwhen you need one specific remote URL. - Use
git branch -rfor remote-tracking branches, not for remote repository names. - Run
git fetch --all --prunebefore checking remote branches if your local references may be stale.
Frequently asked questions about listing Git remotes
How do I list remote repositories in Git?
Run git remote inside the local repository. It prints the names of configured remotes. To include URLs, run git remote -v.
How do I see the remote URL for origin?
Run git remote get-url origin. You can also run git remote -v to see the fetch and push URLs for all configured remotes.
Does git remote list all repositories in my GitHub account?
No. git remote only lists remotes configured in the current local repository. It does not list every repository in a GitHub, GitLab, or Bitbucket account.
How do I list all remote branches in Git?
Use git branch -r to list remote-tracking branches known to your local repository. To update that list first, run git fetch --all --prune.
Why does git remote show no output?
It usually means no remote has been added to the current local repository. Use git remote add <name> <url> to add one, or check that you are in the correct project directory.
Editorial QA checklist for this Git remote list tutorial
- Confirm that the tutorial clearly distinguishes remote repository names from remote branch names.
- Check that
git remote,git remote -v, andgit remote get-urlare explained with separate use cases. - Verify that command examples use command-line code blocks and output examples use output code blocks.
- Ensure the article does not imply that
git remotelists all repositories in a hosting account. - Check that troubleshooting covers both no configured remotes and running the command outside a Git repository.
Conclusion: checking configured remote repositories in Git
In this tutorial, we learned how to display the list of remote repositories configured in a local Git repository. Use git remote for remote names, git remote -v for names with URLs, and git remote show <name> when you need more detailed tracking information.
TutorialKart.com