You committed to `feature-a` but the commit belongs on `feature-b`, and `feature-a` has other commits after it.
IntermediateScenarioRebase, Cherry-pick and History Rewriting
Answer
Situation read → One commit is in the wrong place in the middle of unpushed history.
What I'd do →
git switch feature-b && git cherry-pick <sha>.- Back on
feature-a:git rebase -i <sha>^anddropthe commit. - Resolve conflicts if later commits relied on it.
Why → Cherry-pick copies it to the right branch, and rebase removes the original.
Interview tip → If the branches are pushed and shared, revert instead of dropping.
More on Rebase, Cherry-pick and History Rewriting
Your PR branch has ten commits like "wip", "fix typo", "oops". How do you clean it up before review?BeginnerYou want the database migration commit to come before the code that uses it.BeginnerA critical fix on `main` must go to the `release/4.1` branch only.BeginnerYou must backport a feature made of 6 commits, including one merge commit.IntermediateBranch B was built on top of branch A. A was squash-merged into `main`, and now B shows A's commits again.IntermediateDuring review you get ten small change requests on old commits. How do you apply them cleanly?Intermediate