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.)

- 64,193
- 61
- 179
- 261
-
13You mean you've modified the default refspec, so that `git fetch` and `git remote update` don't fetch all the remote's branches? Because otherwise you could just fetch then use `git branch -r`... – Cascabel Aug 12 '10 at 23:40
-
2I must have. `git branch -r` was only showing me remote branches that I had tracked locally. It's working better now. – James A. Rosen Aug 13 '10 at 00:02
-
`git remote show origin` – Ahmed Nabil Jan 09 '23 at 12:24
22 Answers
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
-
27You can also do `git ls-remote [url]` so you don't have to clone it first :) – Zsub Oct 14 '13 at 15:33
-
29@Stephan: are you sure about this? `git branch -r`also did not work for me. It's just listing the branches already tracked locally. But `git ls-remote --heads` listed all branches available on the remote repository ... – rexford Oct 17 '14 at 08:58
-
@Stephan: looks like you're right, anyway. The comment by nielsbot below resolved this issue for me: _seems this doesn't list all remote branches if I clone from an existing pulled repo and then manually point origin at the git server._ – rexford Oct 17 '14 at 09:05
-
Looks like if your remote is *origin* you can skip referencing it, as it's the default. – alex Feb 02 '16 at 08:56
-
2If one wants to fetch from the branches listed via `git ls-remote` (and not listed at `git branch -r`), one has to execute `git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"` before fetching as described at http://stackoverflow.com/a/26649770/873282. – koppor Feb 14 '16 at 13:02
-
Option -r causes the remote-tracking branches to be listed, and option -a shows both local and remote branches. – sandalone Oct 23 '17 at 12:22
-
17Don't forget to do `git fetch --all` before to get all the current remote branches. – A. Attia May 04 '18 at 12:22
-
4The first part of this answer is wrong. Out of the box without modifying refspec anywhere, `git branch -r` simply does not list all remote branches in all cases. Moreover, because it cannot reliably get all branches, it really shouldn't be trusted in the other "90%" cases either. – Matthew Jun 19 '18 at 14:24
-
4probably a good idea to mention that `git fetch` should be run first right? – Alexander Mills Aug 05 '18 at 16:53
-
@rexford made a valid point. `git branch -r` tells you at what remote branches your (or just fetched) local branches point at. it does not tell you if they actually exist or not at origin. Yes, it's a common case that it HAPPENS to be the correct list, but not always (for 5 years at 2 jobs I never hit a mismatch). `git ls-remote --heads` actually lists only existing remote branches. – SwissNavy Jul 23 '20 at 14:02
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)

- 30,738
- 21
- 105
- 131

- 42,571
- 24
- 140
- 158
-
1
-
3
-
3@PiotrDobrogost Yes! `branch_that_is_not_tracked` is a branch that is not tracked by any local git branch. However, it has been fetched to the local repository (so there is a remote branch). For some strange reason `git remote show` calls this state `tracked`, even though there is no local branch that tracks the remote. In this case, the opposite of `tracked` is `new`, meaning "not fetched". – Klas Mellbourn Oct 11 '15 at 19:17
-
-
1This caught a special case I had where I had pulled a remote branch locally which had then been removed on the remote. Then `git branch -r` suggests that there is a remote branch still, but `git remote show origin` shows that `refs/remotes/origin/my-now-dead-branch stale (use 'git remote prune' to remove)`. Much more useful! – icc97 Oct 19 '18 at 09:16
-
it works good, but impossible to parse in bash to get just branches list – Oleg Abrazhaev Jun 23 '21 at 16:17
-
`git remote show origin` shows stale branches, i.e., branches that do not exist on remote anymore. Doing `git remote prune origin` deletes the stale branches, and then the output matches what `git branch -r` shows. – Yatharth Agarwal May 08 '23 at 15:01
-
Also, I had to run `git remote update origin` for unclear reasons, before git actually properly pulled all remote branches. See https://stackoverflow.com/a/11624159/1292652 – Yatharth Agarwal May 08 '23 at 15:08
Using git branch -r
lists all remote branches and git branch -a
lists all branches on local and remote. These lists get outdated though. To keep these lists up-to-date, run
git remote update --prune
which will update your local branch list with all new ones from the remote and remove any that are no longer there. Running this update command without the --prune will retrieve new branches but not delete ones no longer on the remote.
You can speed up this update by specifying a remote, otherwise it will pull updates from all remotes you have added, like so
git remote update --prune origin

- 1,597
- 14
- 14
-
2
-
Note to self: `git remote update --prune` is equal to `git fetch --all --prune` – M Imam Pratama Jan 23 '22 at 00:39
git branch -a | grep remotes/*

- 20,443
- 10
- 63
- 83
-
11This is basically equivalent to `git branch -r`, which the OP said wasn't good enough. – Cascabel Aug 12 '10 at 23:10
-
11actually both `git branch -a` and `git branch -r` list all remote branches for me, I'm not sure if what the OP said is true. I just setup a test repository and verified this (only had master tracking origin/master but still saw all remote branches with both flags). – Idan K Aug 13 '10 at 11:01
-
2seems this doesn't list all remote branches if I clone from an existing pulled repo and then manually point origin at the git server. The accepted answer handles this case. – nielsbot Oct 17 '13 at 00:59
-
This solution doesn't seem to list remote branches created since I last fetched. – Anubian Noob Jul 06 '15 at 13:56
-
The strange thing: For years I've used `git fetch` followed by `git branch -a`, which only recently started to fail for me. Perhaps git behaviour was changed? – Sebastian Mach Aug 17 '15 at 11:43
But
git branch -ar
should do it.

- 610
- 5
- 11
-
51Passing in both arguments is redundant. `-r` returns _only_ remote branches. `-a` returns both local _and_ remote branches. Thus, `git branch -a` and `git branch -ar` both yield the same output. – Walter Roman Jan 04 '14 at 00:12

- 3,751
- 7
- 53
- 76

- 4,543
- 4
- 33
- 34
-
-
1This is the only command that also lists my branch I accidentally pushed without `heads/` in `refs/heads/features/my-branch`, thanks! – msa Feb 11 '19 at 11:13
-
I like this. If you want to filter then you can use grep like this: git ls-remote | grep "your_filter". – marcello Jun 25 '20 at 19:13
You also may do git fetch
followed by a git branch -r
. Without fetch you will not see the most current branches.

- 1,076
- 9
- 5
Just run a git fetch
command. It will pull all the remote branches to your local repository, and then do a git branch -a
to list all the branches.

- 30,738
- 21
- 105
- 131

- 276
- 3
- 9
Try this...
git fetch origin
git branch -a

- 30,738
- 21
- 105
- 131

- 158
- 1
- 6
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

- 31,877
- 16
- 137
- 115
With Git Bash, you can use:
git branch -a

- 30,738
- 21
- 105
- 131

- 203
- 1
- 4
- 7
The best command to run is git remote show [remote]
. This will show all branches, remote and local, tracked and untracked.
Here's an example from an open source project:
> git remote show origin
* remote origin
Fetch URL: https://github.com/OneBusAway/onebusaway-android
Push URL: https://github.com/OneBusAway/onebusaway-android
HEAD branch: master
Remote branches:
amazon-rc2 new (next fetch will store in remotes/origin)
amazon-rc3 new (next fetch will store in remotes/origin)
arrivalStyleBDefault new (next fetch will store in remotes/origin)
develop tracked
master tracked
refs/remotes/origin/branding stale (use 'git remote prune' to remove)
Local branches configured for 'git pull':
develop merges with remote develop
master merges with remote master
Local refs configured for 'git push':
develop pushes to develop (local out of date)
master pushes to master (up to date)
If we just want to get the remote branches, we can use grep
. The command we'd want to use would be:
grep "\w*\s*(new|tracked)" -E
With this command:
> git remote show origin | grep "\w*\s*(new|tracked)" -E
amazon-rc2 new (next fetch will store in remotes/origin)
amazon-rc3 new (next fetch will store in remotes/origin)
arrivalStyleBDefault new (next fetch will store in remotes/origin)
develop tracked
master tracked
You can also create an alias for this:
git config --global alias.branches "!git remote show origin | grep \w*\s*(new|tracked) -E"
Then you can just run git branches
.

- 13,426
- 6
- 53
- 75
Assuming you have the following branches on a remote repository:
git branch -a
gives you:
*remotes/origin/release/1.5.0
remotes/origin/release/1.5.1
remotes/origin/release/1.5.2
remotes/origin/release/1.5.3
remotes/origin/release/1.6.0
Based on above result command git branch -rl '*/origin/release/1.5*'
gives you this:
origin/release/1.5.1
origin/release/1.5.2
origin/release/1.5.3
-r
stands for remote
-l
list using <pattern>

- 126
- 1
- 1
The accepted answer works for me. But I found it more useful to have the commits sorted starting with the most recent.
git branch -r --sort=-committerdate

- 902
- 1
- 14
- 19
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.

- 30,738
- 21
- 105
- 131

- 42,291
- 14
- 186
- 151
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'

- 30,738
- 21
- 105
- 131

- 16,657
- 15
- 135
- 147
If there's a remote branch that you know should be listed, but it isn't getting listed, you might want to verify that your origin is set up properly with this:
git remote show origin
If that's all good, maybe you should run an update:
git remote update
Assuming that runs successfully, you should be able to do what the other answers say:
git branch -r

- 20,617
- 19
- 137
- 193
Using this command,
git log -r --oneline --no-merges --simplify-by-decoration --pretty=format:"%n %Cred CommitID %Creset: %h %n %Cred Remote Branch %Creset :%d %n %Cred Commit Message %Creset: %s %n"
CommitID : 27385d919
Remote Branch : (origin/ALPHA)
Commit Message : New branch created
It lists all remote branches including commit messages and commit IDs that are referred to by remote branches.

- 30,738
- 21
- 105
- 131

- 1,767
- 18
- 12
Make sure that the remote origin you are listing is really the repository that you want and not an older clone.

- 11
What about stale branches?
The other answers don't account for stale branches. Stale branches are references to remote branches that don't actually exist on remote anymore.
The top-voted answer does not return stale branches:
git branch -r
However, if you run this, you will get stale branches:
git remote show <remote>
To delete the stale branches, you can do
git remote prune <remote>
What if git is not fetching all remote branches?
Sometimes this happens, where git pull
or git fetch
does not pull branches from origin.
To fix that, take a look at this question. In particular, you might want to run:
git remote update <remote>
Then when you do git fetch
, all remote branches will actually be fetched.

- 4,385
- 2
- 24
- 53