Git 恢复 Heroku 中的最后一次提交

发布于 2024-10-21 05:01:58 字数 822 浏览 2 评论 0原文

我做了一个提交并将其推送到 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

聽兲甴掵 2024-10-28 05:01:58

如果您已在本地恢复提交,则可能需要使用 -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.

再浓的妆也掩不了殇 2024-10-28 05:01:58

来自 http://devcenter.heroku.com/articles/releases#rollback

使用回滚回滚到上一个版本的命令:

$ heroku rollback
Rolled back to v51

您可以选择指定另一个目标版本:

$ heroku rollback v40
Rolled back to v40

From http://devcenter.heroku.com/articles/releases#rollback

Use the rollback command to roll back to the last release:

$ heroku rollback
Rolled back to v51

You may choose to specify another release to target:

$ heroku rollback v40
Rolled back to v40
单身情人 2024-10-28 05:01:58

鉴于您已经推送到其他(公共?)存储库,解决此问题的最佳方法可能是在本地撤消 git reset ,然后执行 git revert 来创建一个新的提交可以逆转错误提交的影响。然后再次推动一切。所以一步一步:

  1. 所以首先 git reset --hard origin/mastergit reset --hard heroku/master (或者任何你的heroku跟踪分支被称为),以便让您的本地 master 恢复错误的提交。这将消除工作副本中任何未完成的更改,因此请小心。

  2. 然后 git revert HEAD 创建一个新的提交(它将提示您输入提交消息)。

  3. 然后像平常一样推动。

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 a git revert to create a new commit that reverses the effects of the bad commit. Then push everything again. So step by step:

  1. So first git reset --hard origin/master or git reset --hard heroku/master (or whatever your heroku tracking branch is called), in order to get your local master back the bad commit. This will blow away any outstanding changes in your working copy, so be careful.

  2. Then git revert HEAD to create a new commit (it will prompt you for a commit message).

  3. Then push as you usually would.

血之狂魔 2024-10-28 05:01:58

这就是我所做的。首先,我使用旧提交创建了一个新分支:

git checkout -b old-rev <commit-id>

然后我将本地存储库上的旧分支运行到heroku的master:

git push -f heroku old-rev:master

当我完成旧版本并准备好访问时新版本:

git checkout master
git push heroku master
git branch -d old-rev  # deletes the old branch; warns if there will be data loss

Here's what I did. First, I created a new branch with the old commit:

git checkout -b old-rev <commit-id>

Then I ran push -f the old branch on the local repo to heroku's master:

git push -f heroku old-rev:master

When I'm done with the old version and ready to get to the new version:

git checkout master
git push heroku master
git branch -d old-rev  # deletes the old branch; warns if there will be data loss
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文