DEV Community

Cover image for mistakenly run git reset --hard HEAD~1.  [SOLVED]
Ritik Soni
Ritik Soni

Posted on

mistakenly run git reset --hard HEAD~1. [SOLVED]

for your kind info, this command takes you back to the last commit that has been pushed to Github!

if you mistakenly run this command git reset --hard HEAD~1 so just do

1 . git reflog

you will have your git commit history, like this:-

caee549 (HEAD -> master, origin/master) HEAD@{2}: reset: moving to HEAD~1
237ec6c HEAD@{3}: commit: <<your last git-committed message here>>

in my case, I want to go back on 237ec6c this commit:-

  1. git reset --hard 237ec6c

and voila!
hope this helps!
if not check out this one:- stackoverflow

Top comments (0)