I was on a feature branch with changes committed but not pushed. I wanted to run the code as it existed a few weeks back so I ran git reset --soft xxxxx
, followed by git reset --hard
. I foolishly didn't consider that I had changes made. They were committed so they should at least be recoverable, right? I just need to know how to find the commit hash I guess. Any help?
Asked
Active
Viewed 53 times
2
-
4No worries. Check your `HEAD` reflog with a simple `git reflog`. An alternative would be to check directly the specific reflog of that branch with `git reflog
` which will only list previous positions of that branch tip, not all previous `HEAD` positions (possibly more noisy) – Romain Valeri Jul 03 '19 at 13:23 -
@RomainValeri awesome, thanks. That was a stressful few moments worrying I may have just lost a week's work! – cb7 Jul 03 '19 at 13:30
-
The reflog is your friend, if it got committed recently it'll probably be in the reflog (until git does it's gc and packing). If you committed it at some point, you can probably get back to it even if you then reset it. – Elliot Blackburn Jul 03 '19 at 16:34
-
https://stackoverflow.com/search?q=%5Bgit-reset%5D+undo+reset+%22--hard%22 – phd Jul 03 '19 at 17:17