4

Is it possible to list remote git branches from a single remote? The following list branches from all the configured remotes:

git branch -r
Imran
  • 642
  • 6
  • 25
  • You may use `git remote show ` to see branch information for a specific remote, [see here](https://stackoverflow.com/questions/3471827/how-do-i-list-all-remote-branches-in-git-1-7). This would also include some other information. – Tim Biegeleisen Oct 11 '18 at 06:02

4 Answers4

3

use git remote show <remote-name> it will list all branches existed in that remote

Example: git remote show origin or git remote show https://github.com/test/test-repo.git

reference : view docs

2

Just filter the list

git branch -r | grep origin

Replace origin with desired remote's name.

phd
  • 82,685
  • 13
  • 120
  • 165
1

Is it possible to list remote git branches from a single remote?

Git 2.23 (Q3 2019) does update the documentation to answer that very question:

See commit 1fde99c (28 May 2019) by Philip Oakley (PhilipOakley).
(Merged by Junio C Hamano -- gitster -- in commit ecf55ae, 09 Jul 2019)

doc branch: provide examples for listing remote tracking branches

The availability of these pattern selections is not obvious from the man pages.

Provide examples.

The git branch documentation now has:

Listing branches from a specific remote::

------------
$ git branch -r -l '<remote>/<pattern>'                 <1>
$ git for-each-ref 'refs/remotes/<remote>/<pattern>'    <2>
------------
  • <1> Using -a would conflate <remote> with any local branches you happen to have been prefixed with the same <remote> pattern.
  • <2> for-each-ref can take a wide range of options.

Patterns will normally need quoting.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
0

You could use rev-parse instead:

 git rev-parse --abbrev-ref --symbolic --remotes=<remote-name>
alfunx
  • 3,080
  • 1
  • 12
  • 23