2016-12-02 111 views
0

我跟着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 

回答

1

我從來沒有與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

@埃德蒙我給你另一個更新,希望它更清楚一點。 –