How do I list all remote branches in Git 1.7+?

2019-01-20 21:07发布

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

15条回答
做自己的国王
2楼-- · 2019-01-20 21:18

With GitBash, you Can use:

git branch -a

查看更多
3楼-- · 2019-01-20 21:19

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 repo:

> 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)
查看更多
倾城 Initia
4楼-- · 2019-01-20 21:23

Make sure that the remote origin you are listing is really the repository that you want and not an older clone.

查看更多
姐就是有狂的资本
5楼-- · 2019-01-20 21:24
git branch -a | grep remotes/*
查看更多
我只想做你的唯一
6楼-- · 2019-01-20 21:24

But

git branch -ar

should do it.

查看更多
SAY GOODBYE
7楼-- · 2019-01-20 21:25

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

List all remote branches including commit messages,commit Id that are referred by remote branches.

查看更多
登录 后发表回答