如何在git中撤消对远程存储库的初始提交? [英] How to undo the initial commit on a remote repository in git?
本文介绍了如何在git中撤消对远程存储库的初始提交?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果我的第一次提交是错误的,但是又被推送到(当前为私有的)远程服务器上,我该如何撤消该远程计算机上的提交呢?
If my very first commit is wrong, yet pushed to a (currently private) remote, how do I undo that commit on the remote?
我猜我可以先修改然后再按--force?
I'm guessing I can just amend and then push --force?
推荐答案
通过删除HEAD
,您可以将存储库恢复到新状态,在其中可以创建新的初始提交:
By deleting your HEAD
you can restore your repository to a new state, where you can create a new initial commit:
git update-ref -d HEAD
创建新的提交后,您需要将其强制到远程以便覆盖先前的初始提交:
After you create a new commit you will need to force it to the remote in order to overwrite the previous initial commit:
git push --force origin
这篇关于如何在git中撤消对远程存储库的初始提交?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文