Skip to content
gohacks.dev
Tooling

Git Undo Helper

Pick what went wrong in Git, an unwanted commit, a wrong branch, a lost commit, a bad merge, and get the commands to undo it with what each one risks.

Free · No sign-up · Your inputs stay in your browser

Input

Undo almost anything in Git

Output

Undo the last commit, keep the changes

Commands

git reset --soft HEAD~1

The commit disappears and its changes are staged again, ready to recommit differently.

git restore and git switch arrived in Git 2.23 and split the jobs git checkout used to do. Before running anything marked destructive, git status and git stash are free.

Runs in this browser. Nothing you paste is sent to a server.

Rewriting versus reverting

Commits that only exist on your machine can be amended, reset or squashed freely. Once pushed, rewriting them forces everyone who pulled to reconcile, so on shared branches use git revert, which adds a commit that undoes the old one. When you must force-push your own branch, use --force-with-lease, which refuses if someone else pushed in the meantime.

Almost nothing is lost

The reflog records every position HEAD has had, about 90 days back by default, so a commit dropped by a reset or a deleted branch can be found and restored. Uncommitted changes are the exception: git restore and git reset --hard discard work Git never stored. The commands are documented in the Git reference.

Share

Frequently asked questions

How do I undo the last commit but keep my changes?
git reset --soft HEAD~1. The commit is removed and its changes stay staged.
How do I undo a commit that is already pushed?
git revert <sha>, then push. It adds a new commit that reverses the old one, without rewriting history.
Is what I paste sent anywhere?
No. The tool runs entirely in your browser with JavaScript. Nothing you type or paste is sent to our server or stored.

Keep planning

Similar tools