【问题标题】:Doesn't show all remote branchs with git branch -r不使用 git branch -r 显示所有远程分支
【发布时间】:2016-06-14 11:38:19
【问题描述】:

当我执行命令时:

git branch -r,它只是显示:

origin/HEAD -> origin/master
  origin/development-elton
  origin/master

而当执行命令时:

git remote show origin,它的显示:

 remote origin
  Fetch URL: git@bitbucket.org:r2a_/grconsig.git
  Push  URL: git@bitbucket.org:r2a_/grconsig.git
  HEAD branch: master
  Remote branches:
    caio-dev                   new (next fetch will store in remotes/origin)
    controle-usuario           new (next fetch will store in remotes/origin)
    development-elton tracked
    master                     tracked
    rails-admin                new (next fetch will store in remotes/origin)
    **refinancy            new (next fetch will store in remotes/origin)**

如何为我当地的分行再融资?

【问题讨论】:

    标签: git github branch git-branch remote-branch


    【解决方案1】:

    扩展至mipadi's answer:

    查看所有远程分支(使用单个远程):

    git fetch
    git branch -r
    

    查看所有远程分支(带有多个远程):

    git remote -v //shows names and URLs of remotes
    git fetch --all
    git branch -r
    

    【讨论】:

      【解决方案2】:

      如果现有答案不充分,您可以检查您的.git/config 文件。就我而言,我有以下部分:

      [remote "origin"]
              url = https://github.com/John/project1
              fetch = +refs/heads/master:refs/remotes/origin/master
      

      我已将文件编辑为:

      [remote "origin"]
              url = https://github.com/John/project1
              fetch = +refs/heads/*:refs/remotes/origin/*
      

      然后,我可以使用git fetch 获取所有分支。

      如果您使用以下命令更改远程存储库,有时会发生这种情况:

      git remote set-url origin  https://github.com/John/project1
      

      【讨论】:

      • 在添加 [remote "origin"] 之后,我能够从 Gitlab 中 git fetch --all 我的分支。一些解释可以在这里找到:gitguys.com/topics/…
      • 谢谢!这项工作,但我怎样才能将其设置为默认值。它会在每个克隆上创建错误的配置!
      【解决方案3】:

      您需要运行git fetch 以获取最新的分支。

      【讨论】:

        猜你喜欢
        • 2012-09-01
        • 2012-02-04
        • 1970-01-01
        • 2019-12-25
        • 2019-09-28
        • 1970-01-01
        • 2019-05-18
        • 2018-11-18
        • 1970-01-01
        相关资源
        最近更新 更多