簡體   English   中英

重新安裝操作系統后,Heroku推送被拒絕了嗎?

[英]Heroku push is being rejected, after reinstallation of OS?

我正在遵循Michael Hartl制作的教程,但是我傾向於在Linux上進行很多發行。 我從github克隆了我的倉庫,現在做得很好。 但是我不能再推到heroku了,我不確定為什么...

這是我要運行的命令:

$ bundle exec rake test
$ git add -A
$ git commit -m "Use SSL and the Puma webserver in production"
$ git push
$ git push heroku
$ heroku run rake db:migrate

一切正常,直到最后一部分:

git push heroku
warning: push.default is unset; its implicit value is changing in
Git 2.0 from 'matching' to 'simple'. To squelch this message
and maintain the current behavior after the default changes, use:

git config --global push.default matching

To squelch this message and adopt the new behavior now, use:

git config --global push.default simple

When push.default is set to 'matching', git will push local branches
to the remote branches that already exist with the same name.

In Git 2.0, Git will default to the more conservative 'simple'
behavior, which only pushes the current branch to the corresponding
remote branch that 'git pull' uses to update the current branch.

See 'git help config' and search for 'push.default' for further information.
(the 'simple' mode was introduced in Git 1.7.11. Use the similar mode
'current' instead of 'simple' if you sometimes use older versions of Git)

To git@heroku.com:morning-stream-6357.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'git@heroku.com:morning-stream-6357.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

我真的不太確定如何解決這個問題:/有人可以幫忙嗎? 我對此進行了研究,並使用以下命令添加了遠程heroku存儲庫:

git remote add heroku-remote git@heroku.com:project.git

當然,為我的代碼修改它是這樣的:

git remote add heroku-remote git@heroku.com:morning-stream-6357.git

但是我仍然無法從命令行進行推送,我一直在使用heroku deploy按鈕進行推送,該按鈕允許我部署master分支,但是我認為這不是一個好主意,否則我認為它將在本書中提及。 任何幫助將不勝感激。

編輯:以防萬一,我確實安裝了heroku工具帶。

編輯:我之前應該已經指出,我確實已經嘗試過運行此命令:

git push heroku master

但這仍然給我一個錯誤:

jose@jose-desktop:~/Workspace/sample_app$ git push heroku master
To git@heroku.com:morning-stream-6357.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'git@heroku.com:morning-stream-6357.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

我不確定是什么原因造成的,它應該是最新的。 我克隆了倉庫,之前我已經從heroku的github連接中手動進行了部署,所以它應該是最新的。

git pull

結果:

jose@jose-desktop:~/Workspace/sample_app$ git pull
Already up-to-date.

您需要執行git pull heroku master才能在本地合並您的heroku更改。 當您執行git pull它正在執行git pull origin master ,它是github而不是heroku。 因此,您對heroku進行的任何更改都會導致沖突。

另外,您需要使用以下命令從命令行設置git matching選項:

  • git config --global push.default matching

要么

  • git config --global push.default simple

那些告訴git推送哪個分支而不是需要顯式推送,例如使用master分支git push heroku master 那就是該錯誤消息試圖告訴您的內容。

注意:Heroku僅會接受您的master分支,除非您明確告訴它git push heroku yourbranch:master https://devcenter.heroku.com/articles/git

Hartl教程的“ 1.4.1安裝和設置”部分對此進行了介紹,您需要執行以下一項操作:

$ git config --global user.name "Your Name"
$ git config --global user.email your.email@example.com
$ git config --global push.default matching
$ git config --global alias.co checkout

您應該指定要推送到Heroku的分支。

嘗試運行git push heroku master而不是git push Heroku git push heroku master

如果要將主節點以外的其他分支推送到Heroku,則可以執行以下操作:

git push heroku yourBranchName:master

另外-錯誤消息告訴您在再次git pull之前先進行git pull 您可能應該這樣做。

我通過地獄對其進行了修復,並通過heroku的站點創建了一個新的heroku回購,然后添加了回購:

heroku login
heroku git:clone -a whispering-hamlet-1487

不幸的是,這導致在一個目錄中存在“多個” heroku應用程序,因此要遷移數據庫,就像我們在Micheal Hartl的書清單7.30中所設想的那樣,無法再使用此遷移:

heroku run rake db:migrate

相反,必須使用以下命令進行遷移:

heroku run rake db:migrate -app whispering-hamlet-1487

我將它完全寫出來,以防其他任何學習Rails的人發現這一困難,並且將來需要參考它。 您應該用應用名稱替換whispering-hamlet-1487。

不幸的是,我找不到繼續使用舊回購協議的方法,但是說實話這似乎並不重要,好像總pta一樣。 最好放棄這個。 如果有人知道一種方法而不必創建新的回購協議,我將不勝感激,因為我認為在生產過程中這不是最佳的做法。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM