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

后端 未结 19 2230
轮回少年
轮回少年 2020-12-02 03:14

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

相关标签:
19条回答
  • 2020-12-02 04:03

    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

    https://git-scm.com/docs/git-branch

    0 讨论(0)
  • 2020-12-02 04:04

    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
    
    0 讨论(0)
  • 2020-12-02 04:05

    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
    
    0 讨论(0)
  • 2020-12-02 04:05

    You also may do git fetch followed by a git branch -r. Without fetch you will not see the most current branches.

    0 讨论(0)
  • 2020-12-02 04:05

    Try this...

    git fetch origin
    git branch -a
    
    0 讨论(0)
  • 2020-12-02 04:07

    But

    git branch -ar

    should do it.

    0 讨论(0)
提交回复
热议问题