Git rarely deletes anything immediately, even when a command looks destructive. The reflog (git reflog) is a local, per-repository log of every place HEAD has pointed — every commit, checkout, reset, rebase step, and branch switch — and it's the standard way to recover work that seems to have vanished after a reset --hard, a botched rebase, or a deleted branch:
git reflog
# a1b2c3d HEAD@{0}: reset: moving to HEAD~3
# e4f5g6h HEAD@{1}: commit: Add validation logic
# ...
git reset --hard e4f5g6h # recover the commit that the reset above appeared to discard
Commits become truly unreachable and eventually garbage-collected only after they age out of the reflog entirely (weeks, by default configuration) with nothing pointing to them — which is why "I accidentally reset/rebased and lost my work" is very often recoverable, and worth checking the reflog before assuming anything is actually gone. The reflog is local-only, though — it doesn't get pushed anywhere and doesn't help recover work that was never committed locally in the first place (uncommitted working-tree changes discarded by reset --hard or checkout are not in the reflog, since they were never turned into a commit object at all).