我执行了命令
git reset --hard 6eb7d13f32cf110a1122206e58df381c000a987e
git push --force
在我的github存储库上。问题是我使用的完整SHA是不正确的。现在,我的存储库状态太旧了。所以,我试图将存储库恢复到我在执行这两个命令之前推送的最后一次提交。
git reflog
的输出是
6eb7d13 HEAD@{0}: reset: moving to 6eb7d13f32cf110a1122206e58df381c000a987e
4d0a0fd HEAD@{1}: pull: Fast-forward
82859b3 HEAD@{2}: commit: including command to install dependencies
e3c3ab8 HEAD@{3}: clone: from https://github.com/<user>/<repository>.git
第一个输出线指出了我想撤消的错误。
是否有可能还原它?感谢。
答案 0 :(得分:0)
要回到错误重置之前的状态,然后再次按下,重置并再次按下。提交应该仍然存在,未引用的提交通常会持续数周。看起来像是4d0a0fd。
git reset --hard 4d0a0fd
Check everything is ok before pushing!
git push --force
这就是为什么在推动之前应该总是犹豫不决,尤其是推力。在分享错误之前,它会给你时间检查一切正常。