You merged locally and then realised it was wrong. It has not been pushed.
IntermediateScenarioUndoing Mistakes
Answer
Situation read → A local merge commit can simply be dropped.
What I'd do →
git reset --hard ORIG_HEADreturns to the pre-merge tip if you act right after.- Otherwise:
git reset --hard HEAD^1, which moves back to the first parent. - Check with
git log --oneline --graph -5.
Why → The merge is only a commit on your local branch, and nobody else has it.
Interview tip → If already pushed, use git revert -m 1 instead.
More on Undoing Mistakes
You committed on `main` when you meant to be on a feature branch. Nothing is pushed. Fix it.BeginnerYou made a typo in your last commit message and have not pushed.BeginnerA bad commit is already on shared `main`. Others have pulled it. How do you undo it?IntermediateYou ran `git reset --hard` and lost uncommitted-then-committed work. Can you get it back?IntermediateYou need to revert a merge commit on `main`. `git revert` says "commit is a merge but no -m option was given".IntermediateYou deleted a local branch with unmerged work by mistake.Beginner