Heroku + Git:我如何推送到我的远程分支?产地/主被分离

问题描述:

我跟着Heroku的方向克隆我的回购协议:Heroku + Git:我如何推送到我的远程分支?产地/主被分离

Clone the repository 

Use Git to clone indigo-oms's source code to your local machine. 

$ heroku git:clone -a indigo-oms 
$ cd indigo-oms 
Deploy your changes 

Make some changes to the code you just cloned and deploy them to Heroku using Git. 

$ git add . 
$ git commit -am "make it better" 
$ git push heroku master 

但现在每当我试图结帐的主人,它把我送到heroku/master。我希望能够结帐我的origin/master并能够先推送到,然后结帐heroku/master,将我的origin/master更改合并到它中,然后再推送。

它说当我尝试检出起源/主

➜ indigo-oms git:(3f939ff) git co master 
Switched to branch 'master' 
Your branch is up-to-date with 'heroku/master'. 
➜ indigo-oms git:(master) git checkout origin 
error: pathspec 'origin' did not match any file(s) known to git. 
➜ indigo-oms git:(master) git checkout origin/master 
Note: checking out 'origin/master'. 

You are in 'detached HEAD' state. You can look around, make experimental 
changes and commit them, and you can discard any commits you make in this 
state without impacting any branches by performing another checkout. 

If you want to create a new branch to retain commits you create, you may 
do so (now or later) by using -b with the checkout command again. Example: 

    git checkout -b <new-branch-name> 

HEAD is now at 3f939ff... no need for comfirmation 
➜ indigo-oms git:(3f939ff) 

这里是我所看到的,当我运行git remote它超脱:

➜ indigo-oms git:(3f939ff) git remote 
heroku 
origin 

我从来没有与Heroku工作,但我不认为你应该直接使用origin/master分支,因为这是一个跟踪分支,其目的是简单地保持与实体上的master分支同步l远程。

相反,你的工作流程应该看起来可能像下面这样:

# create branch for origin's master 
git checkout origin/master 
git checkout -b o_master 

# create branch for heroku's master 
git checkout heroku/master 
git checkout -b h_master 

如果出现错误,这些分支已经存在,那么就忽略并继续进行下一个步骤。您可以像使用任何两个常规Git分支一样使用这两个分支o_masterh_master。这包括做你的工作,合并,重新定义和推动。至于推送,如果你想推动主分支上的工作回到它的原始库,你应该这样做:

git push origin o_master 
+0

第二个命令它抱怨分支已经存在,主'它发送给'heroku /主' – Edmund

+0

然后它听起来像你的默认出处是'heroku'。但它不应该把你带到'heroku/master';这是一个跟踪分支。 –

+0

@埃德蒙我给你另一个更新,希望它更清楚一点。 –