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 to me whether the command lists all remote branches or only those that are untracked.)
To view your remote branches, simply pass the -r flag to the git branch command. You can inspect remote branches with the usual git checkout and git log commands.
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
remote show
shows all the branches on the remote, including those that are not tracked locally and even those that have not yet been fetched.
git remote show <remote-name>
It also tries to show the status of the branches relative to your local repository:
> git remote show origin * remote origin Fetch URL: C:/git/.\remote_repo.git Push URL: C:/git/.\remote_repo.git HEAD branch: master Remote branches: branch_that_is_not_even_fetched new (next fetch will store in remotes/origin) branch_that_is_not_tracked tracked branch_that_is_tracked tracked master tracked Local branches configured for 'git pull': branch_that_is_tracked merges with remote branch_that_is_tracked master merges with remote master Local refs configured for 'git push': branch_that_is_tracked pushes to branch_that_is_tracked (fast-forwardable) master pushes to master (up to date)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With