Git 恢复 Heroku 中的最后一次提交
我做了一个提交并将其推送到 origin 和 heroku
然后我意识到这是错误的,所以我做了
git reset --soft HEAD^
但是当我推送到 Heroku 时
To [email protected]:app.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to '[email protected]:app.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.
我明白了这个问题。我应该如何进行?我怎样才能恢复最后的heroku提交? (我认为这将是最好的解决方案)
I made acommit and pushed it to origin and heroku
Then I realised it was wrong, so I did
git reset --soft HEAD^
But when I'm pushing to Heroku Im getting
To [email protected]:app.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to '[email protected]:app.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.
I understand the problem. How should I proceed? How can I revert also last heroku commit? (I assume would be the best solution)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
如果您已在本地恢复提交,则可能需要使用
-f
选项进行git Push
来强制提交。此外,您可能还需要查看< a href="https://devcenter.heroku.com/articles/releases" rel="noreferrer">Heroku 版本 这也可能有帮助。
If you've reverted the commit locally you may need to
git push
with a-f
option to force the commit in.Also, you may want to have a look at Heroku releases which may help too.
来自 http://devcenter.heroku.com/articles/releases#rollback
使用回滚回滚到上一个版本的命令:
您可以选择指定另一个目标版本:
From http://devcenter.heroku.com/articles/releases#rollback
Use the rollback command to roll back to the last release:
You may choose to specify another release to target:
鉴于您已经推送到其他(公共?)存储库,解决此问题的最佳方法可能是在本地撤消 git reset ,然后执行 git revert 来创建一个新的提交可以逆转错误提交的影响。然后再次推动一切。所以一步一步:
所以首先
git reset --hard origin/master
或git reset --hard heroku/master
(或者任何你的heroku跟踪分支被称为),以便让您的本地master
恢复错误的提交。这将消除工作副本中任何未完成的更改,因此请小心。然后
git revert HEAD
创建一个新的提交(它将提示您输入提交消息)。然后像平常一样推动。
Given that you have already pushed to other (public?) repositories, the best way to fix this is probably to undo the
git reset
locally, then do agit revert
to create a new commit that reverses the effects of the bad commit. Then push everything again. So step by step:So first
git reset --hard origin/master
orgit reset --hard heroku/master
(or whatever your heroku tracking branch is called), in order to get your localmaster
back the bad commit. This will blow away any outstanding changes in your working copy, so be careful.Then
git revert HEAD
to create a new commit (it will prompt you for a commit message).Then push as you usually would.
这就是我所做的。首先,我使用旧提交创建了一个新分支:
然后我将本地存储库上的旧分支运行到heroku的master:
当我完成旧版本并准备好访问时新版本:
Here's what I did. First, I created a new branch with the old commit:
Then I ran
push -f
the old branch on the local repo to heroku's master:When I'm done with the old version and ready to get to the new version: