You want the database migration commit to come before the code that uses it.
BeginnerScenarioRebase, Cherry-pick and History Rewriting
Answer
Situation read → Commit order is wrong, though the tree content is fine.
What I'd do →
git rebase -i HEAD~5.- Move the
pickline for the migration above the dependent commit. - Resolve conflicts if both touch the same files, then
git rebase --continue. - Run tests at each step:
git rebase -i --exec "make test" HEAD~5.
Why → Each commit should build and pass tests on its own, so bisect stays reliable.
Interview tip → Reordering conflicts are a sign that the commits are not truly independent.
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?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?IntermediateDuring a rebase, "ours" and "theirs" seem backwards. Why?Intermediate