How to List Remote Branches in Git

How to List Remote Branches in Git

This article will introduce how to list remote repositories from your local branch.

Remote repositories are projects hosted on the server, such as Github/Gitlab.

git remote allows us to use a short name (alias) to execute commands instead of typing a whole remote URL.

$ git fetch git@github.com:stwarts/git-demo.git
From github.com:stwarts/git-demo
 * branch            HEAD       -> FETCH_HEAD

Use git remote -v for listing detail of all remotes, to display just the names, use git remote.

The -v option stands for --verbose, which shows the corresponding URL to each name.

$ git remote
origin
$ git remote -v
origin git@github.com:stwarts/git-demo.git (fetch)
origin git@github.com:stwarts/git-demo.git (push)
Enjoying our tutorials? Subscribe to DelftStack on YouTube to support us in creating more high-quality video guides. Subscribe

Related Article - Git Remote