• Home
  • Novels
    • Gods From the Machine
  • Blog
  • Dev Projects
  • Hire Me
  • About
  • FAQ
  • Menu

Andrew Ly

  • Home
  • Novels
    • Gods From the Machine
  • Blog
  • Dev Projects
  • Hire Me
  • About
  • FAQ
computer.jpeg

How to Revert or Undo a Git Hard Reset

October 27, 2020 in Coding, Tutorials

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 :)

Tags: software development, web development, github, terminal, programming, developer
Prev / Next