[英]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.