【问题标题】:How to push your local master branch to Heroku when you've already pushed a feature branch?当你已经推送了一个特性分支时,如何将你的本地主分支推送到 Heroku?
【发布时间】:2013-03-30 20:12:03
【问题描述】:

为了试用一个功能分支,我将它推送给 Heroku 的 master(因为这是它用于您网站的唯一分支),即我做了:

git push heroku feature-foo:master

同时,我对我的本地 master 分支做了一些提交。现在我想把我的本地主人推回 Heroku,但我得到了:

To git@heroku.com:foo-repo.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'git@heroku.com:foo-repo.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. 

这是有道理的,因为 Heroku 的 master 确实在我的 feature-foo 分支上,因此领先于 master。但我不想从 Heroku 中提取和合并——因为这与合并我的 feature-foo 分支相同,我不想这样做。现在,我只想在没有 feature-foo 提交的情况下推送我的本地 master。 (事实上​​,我已经使用了heroku rollback,因此特性-foo 的更改不会在网站上生效。)

我该怎么做?

【问题讨论】:

    标签: git heroku


    【解决方案1】:

    您还可以转到您的站点 heroku 仪表板并从您推出非主分支之前回滚到以前的构建。

    访问dashboard.heroku.com/apps/your-app-goes-here/activity

    在那里你应该看到:

    在您要返回的版本上单击Roll back to here。一旦您回滚到正确的构建,您就可以从 master 推送而无需使用武力。

    【讨论】:

      【解决方案2】:

      答案很简单。强制推动,即

      git push -f heroku master
      

      【讨论】:

      • 是的,事实证明,git 并不是一个特别好的部署工具。使用 git 部署到 heroku 通常需要做一些你在真正的 git 存储库中永远不想做的事情。
      • 您遇到的问题是其他人在 master 上发布并且您的内容落后了。此解决方案将覆盖他们的工作并在以后引起更多问题。
      猜你喜欢
      • 2011-06-12
      • 1970-01-01
      • 2020-08-07
      • 2011-05-05
      • 2011-02-27
      • 2019-12-10
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多