I\'ve tried git branch -r
, but that only lists remote branches that I\'ve tracked locally. How do I find the list of those that I haven\'t? (It doesn\'t matter
I ended up doing a mess shell pipeline to get what I wanted. I just merged branches from the origin remote:
git branch -r --all --merged \
| tail -n +2 \
| grep -P '^ remotes/origin/(?!HEAD)' \
| perl -p -e 's/^ remotes\/origin\///g;s/master\n//g'
The simplest way I found:
git branch -a
Git Branching - Remote Branches
git ls-remote
Git documentation.
For the vast majority[1] of visitors here, the correct and simplest answer to the question "How do I list all remote branches in Git 1.7+?" is:
git branch -r
For a small minority[1] git branch -r
does not work. If git branch -r
does not work try:
git ls-remote --heads <remote-name>
If git branch -r
does not work, then maybe as Cascabel says "you've modified the default refspec, so that git fetch and git remote update don't fetch all the remote's branches".
[1] As of the writing of this footnote 2018-Feb, I looked at the comments and see that the git branch -r
works for the vast majority (about 90% or 125 out of 140).
If git branch -r
does not work, check git config --get remote.origin.fetch
contains a wildcard (*
) as per this answer
I would use:
git branch -av
This command not only shows you the list of all branches, including remote branches starting with /remote
, but it also provides you the *
feedback on what you updated and the last commit comments.
TL;TR;
This is the solution of your problem:
git remote update --prune # To update all remotes
git branch -r # To display remote branches
or:
git remote update --prune # To update all remotes
git branch <TAB> # To display all branches