Reputation: 642
Is it possible to list remote git branches from a single remote? The following list branches from all the configured remotes:
git branch -r
Upvotes: 4
Views: 947
Reputation: 1324347
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 branchesThe 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.
Upvotes: 1
Reputation: 94483
Just filter the list
git branch -r | grep origin
Replace origin
with desired remote's name.
Upvotes: 2
Reputation: 342
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
Upvotes: 3
Reputation: 3140
You could use rev-parse
instead:
git rev-parse --abbrev-ref --symbolic --remotes=<remote-name>
Upvotes: 0