How to get / List all remote branches present in Git repository using command line

How to get all remote branches present in Git repository using command line

So guys, in this article, we are going to learn about getting or Listing all the remote branches name from your git repository using command line. 

There are more methods to check the remote (git repository) branches name as follows:

Method 1: Listing all remote branches name by mentioning current branch with astric symbol (*):

$   git branch -a

Output:


HP@HP-PC MINGW64 /c/xampp/htdocs/project
$ git branch -a
* current_branch
remotes/origin/HEAD -> origin/current_branch
remotes/origin/branch2
remotes/origin/branch3


Method 2: Listing all remote branches name:

$   git branch -r

Output:


HP@HP-PC MINGW64 /c/xampp/htdocs/project
$ git branch -r
remotes/origin/HEAD -> origin/current_branch
remotes/origin/branch2
remotes/origin/branch3



Method 3: Listing all remote branches name with its origin:

$   git remote show origin

Output:


HP@HP-PC MINGW64 /c/xampp/htdocs/project
$ git remote show origin
remote:
* remote origin
Fetch URL: git@gitlab.com:username/project.git
Push URL: git@gitlab.com:username/project.git
HEAD branch: current_branch
Remote branches:
current_branch tracked
branch2 tracked


Method 4: Listing all remote branches name:

$   git branch --all

Output:


HP@HP-PC MINGW64 /c/xampp/htdocs/project
$ git branch --all
* current_branch
remotes/origin/HEAD -> origin/current_branch
remotes/origin/branch2
remotes/origin/branch3


© Copyright - 2018 - 2021 | All rights reserved at Funda of Web IT