← back to diagnosis

merged wrong branch

caution

You merged the wrong branch and need to undo it before pushing.

$ git reset --hard HEAD~1

This moves HEAD back to before the merge commit. The merge is gone locally. Your working directory is restored to the pre-merge state.

$ git revert -m 1 <merge-commit-hash>

The -m 1 flag tells git which parent to revert to (the branch you were on before the merge). This creates a new commit that undoes the merge without rewriting history.