簡體   English   中英

無法在Git中將master分支推送到Heroku

[英]Can't push master branch to Heroku in Git

我正在合作一個項目並從Github克隆了回購,做了一些改動並推到了Heroku。 現在克隆的應用程序的所有密鑰和密碼都是硬編碼的,而不是ENV變量。

所以我創建了ENV變量,將文件添加到.gitignore。 所以這個應用程序在提交歷史記錄中仍然有這些鍵。 我現在所做的是讓作者在Github上創建一個新的repo,從原始應用程序中刪除.git文件並將新代碼推送到新的repo。

所以現在我克隆了新的應用程序,添加了一個新的遠程Heroku應用程序。

heroku git:remote -a myapplication

我的問題是我無法將新應用程序推送到現有的Heroku應用程序。 當我這樣做時,我得到:

error: failed to push some refs to 'git@heroku.com:myapplication.git
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Merge the remote changes (e.g. 'git pull')
hint: before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

所以git pull表示一切都是最新的。

git remote -v輸出

heroku  git@heroku.com:myapplication.git (fetch)
heroku  git@heroku.com:myapplication.git (push)
origin  git@github.com:author/myapplication.git (fetch)
origin  git@github.com:author/myapplication.git (push)

如何將新應用程序推送到現有的heroku應用程序?

更新

我跑了

git push -f heroku master

推了但我有錯誤

   you have not declared a Ruby version in your Gemfile.
   To set your Ruby version add this line to your Gemfile:"
   ruby '1.9.2'"

我以前從來沒有必須指定,現在所有原始的配置變量都不再存儲在Heroku中。

git pull默認會從GitHub中提取,它已經提交了所有提交。

您可能需要:

  • git pull heroku
  • 清理文件(如果合並帶回硬編碼的值)
  • 推動origin
  • 通過heroku命令推送到heroku

Git使用跟蹤分支的概念來知道哪個遠程分支鏈接到本地​​分支。

在你的情況下,你可能有你的本地分支(我想它是master )鏈接到origin/master 所以,當你做git pull ,Git正試圖從git@github.com:author/myapplication.git獲取新內容git@github.com:author/myapplication.git ,這不是想要的行為。

您必須使用以下方法更改跟蹤的分支:

  • git branch --set-upstream-to heroku/my_branch

然后,你可以做一個git pull ,它現在會有所需的行為。 然后像往常一樣推送到heroku。

暫無
暫無

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

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