Andrew Ly

Okay, so you made a mistaken commit and you want to go back in time. Fortunately using this code in the terminal has helped:

git reset --hard HEAD~1

But then you’ve taken you too far and you’ve lost precious commits! All of a sudden you’re back to the very beginning and you have no clue how to get back! Rest assured you can! With this:

git reflog

Using this will bring up a log of all the previous commits you made in the past then with using:

git reset --hard HEAD@{whichever number was next to that commit you want to go back to}

And voila! You’re back in business. Hope this article saved ya time and trouble :)

Originally published at on October 27, 2020.

Andrew Ly

Andrew Ly

Founder of Neo Typewriter. He is a published author, podcast host, digital marketer, and full-stack web developer. Read more at: