我在尝试推送到 Heroku 后收到此错误消息(复制在下方)。我最初设置了一个 facebook canvas 应用程序并选择了在 heroku 选项上托管。它给了我一个 heroku url,我将其作为远程添加到我在我的机器上开发的应用程序上
heroku git:remote -a desolate-springs-1684
但是当我推送的时候,我得到了这个错误
error: failed to push some refs to 'git@heroku.com:desolate-springs-1684.git'
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes (e.g. 'git pull') before pushing again. See the
'Note about fast-forwards' section of 'git push --help' for details.
localhost:nhl michaelmitchell$
我也是这样
git push -f heroku master
但现在我显然必须执行“git pull”。但是,我在'git pull'之后放什么? heroku 网址的名称?或者是其他东西?
最佳答案
强制你的 git push
不是一个好主意,因为你丢失了你或你在你的工作副本中丢失的其他合作者所做的任何提交。
在推送之前,您应该将上游更改 merge 或重新定位到您的本地工作副本中。
在本地 merge 更改
$ git pull heroku master
$ git push heroku master
在本地重新设置更改
$ git pull --rebase heroku master
$ git push heroku master
顺便说一句,既然您已经推送了您的更改,您实际上不需要执行任何其他操作。远程存储库已包含您的所有更改。
如果出于某种原因 $ git status
命令返回过时的引用,只需运行
$ git pull heroku
获取所有远程更改。请注意,除非您指定目标分支(或者您启用了跟踪分支),否则 git pull
只会下载(而不是 merge )上游更改。
另请注意,不应将 Heroku 视为 git 托管。这意味着从 Heroku 执行 git pull
是极其罕见的。相反,您应该使用 git 托管(例如 GitHub 或 BitBucket)来存储您的存储库,并且只执行推送到 Heroku 以部署应用程序。
关于ruby-on-rails - Heroku:如何在 "git pull"之后到 'git push -f',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12415875/