0

If I reset my last commit using git reset --hard HEAD^, how do I undo the reset?

I don't have anything more to ask, but apparently there are length requirements for this message. I'm just writing more here to pass the quality standards.

nev
  • 297
  • 3
  • 13

1 Answers1

3

All changes that are not committed are lost. If it was committed, you can try git reflog to restore it.

This is already asked many times, so please see this one for reference.

Community
  • 1
  • 1
Tatsuyuki Ishi
  • 3,883
  • 3
  • 29
  • 41
  • His problem is because of an accidental `git reset --hard` not `git rebase` – smarber Mar 13 '17 at 14:23
  • reflog can be used, regardless of what kind of destructive operation – Tatsuyuki Ishi Mar 13 '17 at 14:24
  • @TatsuyukiIshi If he nuked his working directory without having committed or stashed, the work really might be lost. Perhaps the IDE has a history feature in such a case. – Tim Biegeleisen Mar 13 '17 at 14:26
  • I agree with you that the cure is the same, however the two questions are a bit different, `rebase` is not `reset --hard`. So your anwser is great to me except the part where you say `This is already asked many times`, a bit confusing I think – smarber Mar 13 '17 at 14:30