【问题标题】:How do I do a git pull to a specific branch?如何执行 git pull 到特定分支?
【发布时间】:2011-07-27 10:49:21
【问题描述】:

我正在尝试从我的 heroku 遥控器中提取信息,我收到以下消息:

>git pull heroku
You asked to pull from the remote 'heroku', but did not specify
a branch. Because this is not the default configured remote

我的本​​地分支是“开发”。

如何从 Heroku 拉到我的本地分支“开发”?

谢谢。

【问题讨论】:

    标签: git


    【解决方案1】:

    更新答案:您需要指定要从哪个分支提取,因为您的本地分支未配置为从herokumaster 提取。

    所以尝试一下:

    git pull heroku master
    

    请记住,您必须先签出 develop 才能将此命令拉到本地分支 develop

    【讨论】:

    • 我的遥控器叫heroku。记住我想要我的本地分支你知道....不是远程分支。当我执行git pull heroku develop 时,我收到一个致命错误,因为没有名为develop 的远程分支。我想做的是从远程的远程主分支heroku拉到我的本地分支develop
    • 如答案所述,master 是远程分支。
    【解决方案2】:

    注意:如果你想从你的develop 分支默认推/拉到heroku/master,你可以配置它:

    git branch --set-upstream-to develop heroku/master
    

    您可以在develop 分支上检查您的合并策略:

    git config branch.develop.merge
    

    注意:作为commented by Animay,由于 Git 1.8,--set-upstream is renamed --set-upstream-to
    --track 也是可能的,although slightly different

    【讨论】:

    • 根据docs--“不再支持'--set-upstream'选项。请改用'--track'或'--set-upstream-to'。”跨度>
    • @Animay 谢谢。我已经相应地编辑了答案。
    【解决方案3】:

    当您拉取时,您必须指定要从哪个远程分支拉取。仅仅从“heroku”中提取是没有任何意义的,因为它可能有多个分支,而 Git 不知道你想要哪个。

    如果你的遥控器上只有一个分支,那么它可能被称为“master”。试试:

    git checkout develop
    git pull heroku master
    

    这会将您放入本地“develop”分支,然后从名为“heroku”的存储库中提取“master”分支。

    【讨论】:

      【解决方案4】:

      在撰写本文时,git pull 命令提供了答案。当我尝试git pull 没有任何进一步的参数时,它为我提供了以下信息:

      rockyinde.desktop% git pull
      remote: Counting objects: 143, done.
      remote: Compressing objects: 100% (95/95), done.
      remote: Total 143 (delta 75), reused 87 (delta 23)
      Receiving objects: 100% (143/143), 29.59 KiB | 0 bytes/s, done.
      Resolving deltas: 100% (75/75), completed with 33 local objects.
      From ssh://git.rockyinde.com:<port>/code/myproject
         2d232ds..1hw1f84  frontline   -> rockyremote/frontline
      
      There is no tracking information for the current branch.
      Please specify which branch you want to merge with.
      See git-pull(1) for details
      
         git pull <remote> <branch>
      
      If you wish to set tracking information for this branch you can do so with:
      
         git branch --set-upstream-to=<remote>/<branch> develop
      

      所以,您只需要查看(在上面的输出中)就是:

      From ssh://git.rockyinde.com:<port>/code/myproject
         2d232ds..1hw1f84  frontline   -> rockyremote/frontline
      

      指定您的remote/branch 信息。所以,就我而言,它是:

      git pull rockyremote frontline
      

      【讨论】:

        猜你喜欢
        • 2021-09-02
        • 2013-12-04
        • 2013-09-30
        • 2011-11-25
        • 2017-12-26
        • 2011-09-15
        • 2012-12-03
        • 2018-09-12
        • 2013-10-09
        相关资源
        最近更新 更多