undo-op
- Inspect
git reflog(orgit reflog show <branch>), find the requested operation, and inspect the entry immediately before it withgit logorgit show HEAD@{N}. - Show that target to the user and confirm it is the desired state.
- If uncommitted work exists, stash it (
git stash -u); never create a checkpoint commit merely to clear the tree. - Restore the affected branch with
git reset --hard HEAD@{N}, thengit stash popif needed.
Use git revert instead when undoing a published commit by adding a new inverse
commit. Reflog recovery rewinds local history; reset --hard discards unstashed
changes.


