Yes, except... again, this is fighting fire with fire.
If you don’t know git internals, mistype a non-obvious command and lose a bunch of commits, then “look in the reflog” advice is frankly adding insult to injury.
The reflog is awesome! It keeps pointers to commits that have been dropped, rewritten by rebases, stuff like that.
Git is garbage collected, even if a commit is dropped from a branch it won't simply disappear immediately afterwards. The object is still in the git repository and it can still be reached, most easily through the reflog. Only when garbage collection is performed will any unreachable commits be deleted.
> It's really hard to lose changes once they've been committed.
I've still managed to do it (or maybe I used git rm to delete some files that weren't committed?) so let me give one more shout out to 'git fsck' which saved me here.
If you ever run into this, you can use `git reflog` to see the history of your local actions. It's possible to revert almost any action with it.
Reset a few commits that you've never pushed to remote? No worries! Just go to `git reflog`, find a point before it happened, and `git reset` to it.
And you're back before "OOPS" :) It's really hard to lose changes once they've been committed.