Help, I merged the wrong branch
Undo a merge you did not mean to make, before or after pushing it.
git merge feature/experiment Merge made by the 'ort' strategy.
The fix
git reset --hard ORIG_HEADPuts your branch back where it was before the merge. Also resets uncommitted changes to tracked files.
Discards uncommitted changes
git revert -m 1 a1b2c3da1b2c3dis the merge commit.-m 1says which side to keep: the branch you merged into.git pushShare the undo.
a1b2c3d is an example. Replace it with your own.
git reset --hard ORIG_HEADBefore
After
Why this works
Before a merge, Git saves where your branch was as ORIG_HEAD, so resetting to it undoes the merge in one go. Do it straight away: the next reset, rebase or pull overwrites ORIG_HEAD. After pushing, revert the merge commit instead. One catch: Git then considers the branch merged, so if you want it in for real later, revert the revert first.