6

为了尝试一个功能分支,我将它推送给 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 更改不会在网站上生效。)

我怎么做?

4

2 回答 2

15

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

git push -f heroku master
于 2013-04-08T17:03:48.150 回答
0

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

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

到达那里后,您应该看到:

在此处输入图像描述 单击Roll back to here要返回的构建。一旦你回滚到正确的构建,你就可以从 master 推送而无需使用武力。

于 2016-11-19T18:04:22.673 回答