How to List all Remote Branches in Git
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.
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
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:
- Stay Connected to: Facebook | Twitter | Google+
- Support us via PayPal Donation
- Subscribe to our email newsletters.
- Tell other sysadmins / friends about Us - Share and Like our posts and services
We are thankful for your never ending support.