How to List Remote Branches in Git

Stewart Nguyen Feb 02, 2024
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)

Related Article - Git Remote