[git commit rollback] How to restore the commit record on github after the code is forcibly overwritten

scene:

One day, after you wrote the code, you accidentally git push origin -fforced the local code to be overwritten, and all the commit records were gone.

recover:

Use the following command to view the commit log:

git reflog

insert image description here
Use the following command to restore:

 git reset --hard 想要回退的版本号
 git push origin -f

insert image description here

Then revert to the version you want

Guess you like

Origin blog.csdn.net/weixin_43853746/article/details/122301574