如何对特定分支执行git pull?

时间:2011-04-01 05:56:25

标签: git

我正试图从我的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拉到我当地的分支'develop'?

感谢。

4 个答案:

答案 0 :(得分:35)

更新的答案:您需要指定要从中提取的分支,因为您的本地分支未配置为从heroku的{​​{1}}提取。

所以尝试类似:

master

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

答案 1 :(得分:6)

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

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

git checkout develop
git pull heroku master

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

答案 2 :(得分:6)

注意:如果您希望从heroku/master分支默认推送/提取到develop,则可以使用以下命令进行配置:

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

您可以使用以下内容检查develop分支上的合并政策:

git config branch.develop.merge

注意:commentedAnimay,因为Git 1.8,--set-upstream is renamed --set-upstream-to--track也是可能的,although slightly different

答案 3 :(得分:3)

在撰写本文时,命令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