The Git undo generator: three questions, one command out
The git undo generator asks pushed or not, keep or discard, shared or solo — 18 states collapse into 4 commands. Pushed to a shared branch? Revert is the only polite undo.
The git undo generator asks three questions — pushed or not, keep or discard, shared or solo — and prints one exact command. No account, nothing uploaded, all in the browser. Pushed to a branch others pull? Revert is the only polite undo. Committed and lost? The reflog still knows.
The shared-branch question is the whole tool. Everything else is convenience; that one is damage control.
git undo generator: the decision table
The sorter runs this lookup cell for cell. Three question gates — where, keep, shared — drop each ticket into one of the chutes. A REFUSED gantry is bolted across the three reset chutes: pushed commits cannot enter.
| 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 commands it prints
# 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>
HEAD~1..HEAD reverts exactly the commits you name — worth knowing even if the tool types it for you. Verify: after git reset --soft HEAD~1 the changes are kept and staged; after the reflog pair, nothing is lost. The phone test: one static page, no server, no analytics, no cookies — it loads in a server room.
what the machine refuses
Shared branch — "pushed to a shared branch" offers one command: revert. The alternatives burn teams.
Own branch — the reset paths differ only in the force-with-lease tail; the tool still hands you the polite path first.
No rebase help — reordering commits? You already know more than the tool teaches.
- git 2.4x command set · browser-only · no account, nothing uploaded
- first published 2026-09-25 · the decision table is the revert-vs-reset record turned into a lookup; every command prints as tested, warnings included
- source: github.com/mrsaynothing/git-undo — plain HTML and JavaScript, no build step, no dependencies