如何在Git 1.7+中列出所有远程分支?
我试过git branch -r ,但只列出了本地跟踪的远程分支。 我如何find那些我没有的列表?  (命令是列出所有远程分支还是只列出所有远程分支并不重要。 
 git ls-remote --heads <remote-name> 
  remote show显示remote show所有分支,包括那些本地没有跟踪的分支,甚至那些还没有被获取的分支。 
 git remote show <remote-name> 
它还试图显示分支机构相对于您本地回购的状态:
 > 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) 
 git branch -a | grep remotes/* 
但
 git branch -ar 
应该这样做。
 使用git branch -r列出所有远程分支和git branch -a列出本地和远程的所有分支。 尽pipe这些列表已经过时了。 要使这些列表保持最新状态,请运行 
 git remote update --prune 
这将更新您的本地分支名单与远程的所有新的,并删除任何不在那里。 不使用–prune运行此更新命令将检索新的分支,但不会删除远程上不再有的分支。
你可以通过指定一个遥控器来加速这个更新,否则它会从你添加的所有遥控器中提取更新
 git remote update --prune origin 
 你也可以做一个git branch -r 。 没有获取你不会看到最新的分支。 
Git分支 – 远程分支
 git ls-remote 
Git文档 。
 最好的命令是运行git remote show [remote] 。 这将显示所有分支,远程和本地,跟踪和untracked。 
以下是一个开源项目的例子:
 > 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) 
 如果我们只想得到远程分支,我们可以使用grep 。 我们想要使用的命令是: 
 grep "\w*\s*(new|tracked)" -E 
有了这个命令:
 > 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 
你也可以为此创build一个别名:
 git config --global alias.branches "!git remote show origin | grep \w*\s*(new|tracked) -E" 
 然后你可以运行git branches 。 
我发现最简单的方法:
 git branch -a 
我最终做了一个乱七八糟的shellpipe道来得到我想要的东西,只是从远程源合并分支:
 git branch -r --all --merged \ | tail -n +2 \ | grep -P '^ remotes/origin/(?!HEAD)' \ | perl -p -e 's/^ remotes\/origin\///g;s/master\n//g' 
TL; TR;
这是你的问题的解决scheme:
 git remote update --prune # To update all remotes git branch -r # To display remote branches 
要么:
 git remote update --prune # To update all remotes git branch <TAB> # To display all branches 
确保你所列出的远程源是你想要的存储库,而不是旧的克隆。
尝试
  git branch -at