git almost never actually deletes anything. most things you think are gone are still recoverable. read this before you do anything drastic.
Every time HEAD moves — commits, resets, checkouts, rebases — git records it in the reflog. This is your black box. Even if you can't see a commit in git log, it almost certainly still exists.
git reflog This shows you every place HEAD has been. Find the hash of where you want to go back to, then:
git reset --hard <hash> Reflog entries expire after 90 days by default. If the mistake happened recently, the data is there.
To be honest with you — there are a few things that are genuinely gone:
git clean -f on untracked filesgit stash drop with no referenceRun git status and git log to understand where you are
Run git reflog to see your recent history — your escape hatch
If the command has --force or --hard, understand what it does first
If you pushed, coordinate with your team before rewriting history
When in doubt, create a backup branch: git branch backup-just-in-case