Quick preface, I have very little experience with git and other console based programs.
That being said, the problem at hand is that I used git reset --hard HEAD~ to roll back to a previous commit due to some corruption, but I ended up going one commit too far. Is there any way to undo the rollback or go forward a commit? I haven't synced it to the web yet.
git reflog | head should show you the commit ids you need to recover your lost commit.
xxxxxxx HEAD@{0}: reset: moving to HEAD~
yyyyyyy Your lost commit?
You can try the following
git checkout yyyyyy -b newbranch
git log newbranch
or
git cherry-pick yyyyyy
git reset HEAD@{1}
This takes you back to before you reset wrong, assuming only ONE commit too far. From there you can reset again to the correct commit.
git reflog
Use this to see a list of updates. Each update is assigned with a HEAD number (for example, HEAD@{1}: reset: blah..blah..), you use this number to point to where you want to go just like the first command.
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