I wanted to discard changes in the current branch and without committing, I accidentally entered the command git revert HEAD. The changes in the prev branch (committed earlier) appear to be lost?
How can I undo agit revert HEAD command?
You can do
git reset --hard HEAD~1
It will take you to the commit before the current HEAD.
If you did not do a git push after reverting the commit, then Bidhan's answer is spot on. However, if you have pushed since then, you will want to revert your revert by simply doing git revert HEAD again.
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