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.
About this tool
Method, assumptions, practical next steps, and limits.
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.