如何在`git push`之后在本地和远程地方撤销`git commit` [英] How can I undo a `git commit` locally and on a remote after `git push`
本文介绍了如何在`git push`之后在本地和远程地方撤销`git commit`的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经执行 git commit
,然后执行 git push
。
$ git log
commit 364705c23011b0fc6a7ca2d80c86cef4a7c4db7ac8
我该如何在本地和远程存储库上还原这个更改?作者:Michael Silver< Michael Silver@gmail.com>
日期:星期二6月12日12:24:23 2011 -0700
解决方案
git reset --hard HEAD〜1
git push -f< remote> <分支>
(示例推送: git push -f这些将会取消上次提交并将更新后的历史记录推送到远程。您需要传递
-f
,因为您要替换远程中的上游历史记录。
I have performed git commit
followed by a git push
. How can I revert that change on both local and remote repositories?
$ git log
commit 364705c23011b0fc6a7ca2d80c86cef4a7c4db7ac8
Author: Michael Silver <Michael Silver@gmail.com>
Date: Tue Jun 11 12:24:23 2011 -0700
解决方案
git reset --hard HEAD~1
git push -f <remote> <branch>
(Example push: git push -f origin bugfix/bug123
)
This will undo the last commit and push the updated history to the remote. You need to pass the -f
because you're replacing upstream history in the remote.
这篇关于如何在`git push`之后在本地和远程地方撤销`git commit`的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文