How to List all Remote Branches in Git

undefined

This tutorial will help you to list all branches available on remote git repository. It is helpful you to find names of branches, which has been created on remote repository by someone and you want to checkout this on your local repository.

Option 1:

Firstly run git fetch command to update your remote-tracking branches under refs/remotes/<remote_name>/.

$ git fetch

Now use following command to list all branches on local and all remote repositories.

$ git branch -a 

//output

* development
  master
  staging
  remotes/origin/development
  remotes/origin/master
  remotes/origin/staging

Option 2:

You can also use ls-remote option to list remote repositories without updating your remote-tracking branches.

$ git ls-remote 

//output

5ffcb8136c48423f858e49c2df78fc7ac419fe39        HEAD
5ffcb8136c48423f858e49c2df78fc7ac419fe39        refs/heads/development
5ffcb8136c48423f858e49c2df78fc7ac419fe39        refs/heads/master
5ffcb8136c48423f858e49c2df78fc7ac419fe39        refs/heads/staging

If repository connected with multiple remotes, use following command syntax.

$ git ls-remote --heads <remote_name>

If You Appreciate What We Do Here On Mimastech, You Should Consider:

  1. Stay Connected to: Facebook | Twitter | Google+
  2. Support us via PayPal Donation
  3. Subscribe to our email newsletters.
  4. Tell other sysadmins / friends about Us - Share and Like our posts and services

We are thankful for your never ending support.

Leave a Reply

Your email address will not be published. Required fields are marked *