git add 的时候没仔细看,结果发现提交的版本中把整个仓库的文件给删除了 而且被我 commit + push 到远程服务器了,该怎么恢复啊,重新 add + commit + push 上传的速度太慢了 T。T
走同样的路,发现不同的人生
You can directly go back to the last submission and then force push.
#假定当前正位于该错误提交,而其父提交为正确的提交 git reset --hard HEAD~ git push -f
Please note that using the git push 的 -f parameter may cause pull conflicts for others on multi-person collaboration projects.
git push
-f
If you are not sure which commit to revert to, you can use git reflog 查看头指针的变动历史,然后使用 git reset --hard <commit hash>.
git reflog
git reset --hard <commit hash>
You can directly go back to the last submission and then force push.
Please note that using the
git push
的-f
parameter may cause pull conflicts for others on multi-person collaboration projects.If you are not sure which commit to revert to, you can use
git reflog
查看头指针的变动历史,然后使用git reset --hard <commit hash>
.