有没有办法将我最后一次推送到Git? [英] Is there a way to rollback my last push to Git?
本文介绍了有没有办法将我最后一次推送到Git?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
可能存在重复:
撤销'git push'
Possible Duplicates:
Undoing a 'git push'
我推送了一些不好的代码,并且我是存储库的唯一用户。如何回滚我的最后一次提交?
I have pushed some bad code, and I am the only user of the repository. How can I rollback my last commit?
推荐答案
因为您是唯一的用户:
git reset --hard HEAD@{1}
git push -f
git reset --hard HEAD@{1}
(基本上,返回一个提交,强制推送回购,然后再返回 - 如果您要移除最后一步不关心提交)
( basically, go back one commit, force push to the repo, then go back again - remove the last step if you don't care about the commit )
在不对本地回购进行任何更改的情况下,您还可以执行以下操作:
Without doing any changes to your local repo, you can also do something like:
git push -f origin <sha_of_previous_commit>:master
通常,在公开的回购协议中,执行 git revert
然后
Generally, in published repos, it is safer to do git revert
and then git push
这篇关于有没有办法将我最后一次推送到Git?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文