The git undo generator: three questions in, one command out
Pushed or not, keep or discard, shared or solo — the decision table behind the tool, printed in full, with the reflog rescue's 90-day clock.
Three questions — pushed or not, keep or discard, shared or solo — one exact command out, no account, all in the browser.
Pushed and others pull the branch? Revert is the only polite undo.
Committed and lost? Reflog rescue — dropped commits stay reachable ~90 days.
01THE SORTER, LIVE
eighteen states queue in the hopper — keys 1 · 2 · 3 throw the levers, the drum sorts the ticket
WHERE PUSHED · ROUTED REVERT · VERDICT THE ONLY POLITE UNDO · RESETS REFUSED
the situation is "pushed to a shared branch" — the only command it offers is revert, because the alternatives burn teams.
18 states on the panel — three questions, 3 × 3 × 2 — and most collapse into the same handful of commands.
the REFUSED gantry is bolted across the three reset chutes — permanent structure, not a lever: pushed commits cannot enter
02THE DECISION TABLE
the sorter's whole brain, printed — the machine runs this lookup cell for cell, no account, nothing uploaded
| Command | History | Working tree | Shared branch? |
|---|---|---|---|
git reset --soft HEAD~1 | moves back 1 | changes kept, staged | no — rewrite |
git reset HEAD~1 | moves back 1 | changes kept, unstaged | no — rewrite |
git reset --hard HEAD~1 | moves back 1 | changes discarded | no — destructive |
git revert HEAD | adds an undo commit | untouched | yes — the safe move |
git reflog + git switch -c recovery <sha> | nothing lost | restored from reflog | rescue after anything |
The shared-branch question is the whole tool. Everything else is convenience; that one is damage control.
03THE COMMANDS IT PRINTS
four commands cover almost every mess — copy the block, warning comments included
# committed, not pushed, keep the changes staged
git reset --soft HEAD~1
# committed, not pushed, keep the changes unstaged
git reset HEAD~1
# pushed, others pull this branch — the only polite undo
git revert --no-edit HEAD~1..HEAD
git push
# committed and lost — reflog knows for ~90 days
git reflog
git switch -c recovery <sha-from-the-list>
verify: git reset --soft HEAD~1 → changes kept, staged · git reflog + git switch -c recovery <sha> → nothing lost, restored from reflog
HEAD~1..HEAD reverts exactly the commits you name — worth knowing even if the tool types it for you04WHAT THE MACHINE REFUSES
the refusals are the feature — where the record declines to guess, the sorter prints the wall
source: github.com/mrsaynothing/git-undo — plain HTML and JavaScript, no build step, no dependencies. Fork it, restyle it, rip out my wording.
If it saves you one reflog session this year, it has paid for the afternoon it took.
end of the generator · nothing fetched · everything local