【问题标题】:How can I retrieve git remote branches?如何检索 git 远程分支?
【发布时间】:2015-03-29 09:24:38
【问题描述】:

我显然遗漏了一些东西,因为我无法从我在本地使用的 git repo 获取服务器上我需要的远程分支。

在我的本地开发环境中

我运行git remote -v,它给了我:

origin  git@git.example.com:the_repo (fetch)
origin  git@git.example.com:the_repo (push)

我运行git branch,它给了我:

* live
  master

在我的实时服务器环境中

我运行git remote -v,它给了我:

origin  git@git.example.com:the_repo (fetch)
origin  git@git.example.com:the_repo (push)

我运行git branch,它给了我:

* master

当我尝试通过运行git fetchgit fetch origin 来解决这种情况时,在再次运行git branch 时仍然看不到我的live 分支。我怀疑这是因为git branch 只列出了我当地的分支机构。

如何在本地签出之前获取 repo 的远程分支并列出它们?

非常感谢 - 非常感谢。

【问题讨论】:

    标签: git version-control git-branch git-remote git-checkout


    【解决方案1】:

    Matt 和 CodingWithSpike 的回答都符合我的目的(谢谢)。此外,我刚刚发现git branch -vv 命令会显示哪些本地分支与哪些远程分支相关联。

    【讨论】:

      【解决方案2】:

      马特的回答是正确的,但只是补充一下:

      git branch -a
      

      将显示“所有”分支,包括本地和远程。

      【讨论】:

        【解决方案3】:

        您可以使用命令git branch -r查看远程分支。

        【讨论】:

        • 正是我需要的。谢谢马特!
        猜你喜欢
        • 2012-10-22
        • 2010-12-19
        • 1970-01-01
        • 1970-01-01
        • 2021-03-20
        • 1970-01-01
        • 2021-03-07
        相关资源
        最近更新 更多