A bug fix commit on `main` must be reverted from `release/3.0`, but later commits touched the same lines.
AdvancedScenarioUndoing Mistakes
Answer
Situation read → A plain revert will conflict because the surrounding code changed.
What I'd do →
git switch release/3.0 && git revert <sha>.- Resolve conflicts using
zdiff3markers, comparing against the original commit's diff:git show <sha>. - If dependent commits are required, decide: revert those too, or fix forward with a targeted patch.
- Run the release test suite, then open a PR to the release branch.
Why → Revert is a reverse cherry-pick, so it is only as clean as the surrounding context.
Interview tip → Say you would ask whether the release needs the revert at all, or a smaller targeted fix.
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