Find the git command for the situation you are in — committed to the wrong branch, need to undo a push — with its safety level and an explanation.
12 of 12 situations · this one is rewrites history
Read the explanation before running it.
The commit was premature, or the message was wrong, and nothing has been pushed.
git reset --soft HEAD~1Moves the branch back one commit and leaves everything staged, exactly as it was before you committed.
Nothing is run here and no repository is touched — these are commands to read and then run yourself. The right command also depends on things this page cannot see: whether the commit is pushed, whether anyone else has pulled it, and whether a rebase or merge is already in progress. Read the explanation before running anything marked as rewriting history or destructive.
Git Command Builder runs entirely on your device — nothing is uploaded.
You’re on the Free plan. Compare plans
Git documentation is organised by command, and the problem you have is not. "I committed to the wrong branch" is the thing in your head; `git cherry-pick` is the answer, and no amount of reading the manual page for cherry-pick helps if you do not already know that is the word you need. This page is indexed the other way round.
Every answer carries its safety level, because several of the common answers rewrite history and a few can lose work. A page that hands you `git reset --hard` because you asked how to undo something, without saying what it discards, is worse than no page at all.
The explanations say what the command does to your repository rather than restating its flags. Where two commands would both work, the safer one is given and the trade-off is named — `git revert` leaves an extra commit in the history and is the right answer on a shared branch precisely because it does not rewrite anything.
Nothing is executed. These are commands to read, understand and then run yourself, in your own terminal, where you can see what state your repository is actually in.
Because the command name is the thing you do not know. Searching for `cherry-pick` requires already knowing that cherry-pick is what moves a commit between branches, which is exactly the knowledge the search was supposed to supply.
No. Nothing here touches a repository. The commands are for you to read and then run yourself, which also means you can see your own state before you do.
`git reset --soft HEAD~1` moves the branch back one commit and leaves everything staged. The `--soft` is what makes it safe; `--hard` on the same command discards the changes entirely, which is the single most common way people lose work in git.
Reset moves the branch pointer, so the commit disappears from the history. Revert adds a new commit that undoes the old one, leaving both in the history. On a branch anyone else has pulled, revert is the right answer — reset rewrites history that other people already have.
No, deliberately. It covers the situations people actually search for. A tool trying to cover everything becomes the documentation again, which is the thing that was not helping.