I am in a very stupid situation now. Playing with git-hub for windows I have reverted my last two local commits, and I can't undo this (revert command). A lot of code have gone. Is it posible restore reverted commits? I am new at git.
No worries. You can get your code back.
One way is to revert the commits that reverted your work. List your last commits using git log then git revert your previous reverts.
Another is to reset your master to a point before your reverts. This will be the cleanest way if the two last commands were the two reverts. Then you can do
git reset --hard HEAD~2
As Srdjan Grubor points out, if you cannot find your commits using git log you can go look for them in git reflog which shows you where your HEAD has been lately, even after such commands as git reset.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With