How to list remote branch without web request?

101 views Asked by At

i just want to list my local remote branches. but when i run git remote show origin, it needs to take a request to the server. How can i do ?

3

There are 3 answers

0
poke On BEST ANSWER

git branch -r will list all remote-tracking branches that exist in your local repository:

$ git branch -r
  origin/HEAD -> origin/master
  origin/master

You can also use the -a option to get all branches that exist in your local repository:

$ git branch -a
* master
  remotes/origin/HEAD -> origin/master
  remotes/origin/master
0
Noufal Ibrahim On

The -a option to git branch will list all remote-tracking branches. This is mentioned in the manual page.

0
CodeWizard On

As mentioned above.

git branch -a

will display all your branches.

Important:

git branch -a will indeed display the list of branches but those are the branched currently tracked under your .git folder. As a best practice you should update your .git folder before listing the branches.

The update is done using the git fetch --all --prune

The --all will update all the branches and tags.
The --prune will remove all the deleted branches.