Git Reflog
git reflog lists every move of HEAD in your repository: commits, checkouts, resets, merges and rebases.
It is how you find a commit that is no longer on any branch, for example after a git reset --hard. The reflog is local to your computer.
Get back a commit after a reset
git reset --hard HEAD~1
HEAD is now at 99f8584 Add docs line
git reflog
99f8584 HEAD@{0}: reset: moving to HEAD~1
d3c2af2 HEAD@{1}: cherry-pick: Add README
99f8584 HEAD@{2}: checkout: moving from hotfix to main
df31edb HEAD@{3}: commit: Add README
99f8584 HEAD@{4}: checkout: moving from main to hotfix
99f8584 HEAD@{5}: commit: Add docs line
c2ddb8a HEAD@{6}: commit: Add welcome line
21e6719 HEAD@{7}: commit (initial): First release of Hello World!
git reset --hard HEAD@{1}
HEAD is now at d3c2af2 Add README