During a rebase, "ours" and "theirs" seem backwards. Why?
IntermediateScenarioRebase, Cherry-pick and History Rewriting
Answer
Situation read → Rebase replays your commits onto the target, so Git checks out the target and applies your commits one by one.
What I'd do →
- Remember: during rebase, "ours" is the branch being rebased onto (upstream), "theirs" is your commit being replayed.
- To keep your change:
git checkout --theirs file. - To keep upstream's version:
git checkout --ours file. git add file && git rebase --continue.
Why → Git's internal "current branch" is the detached rebase target, so the labels flip compared to merge.
Interview tip → A good interviewer answer: "I avoid the words and read the diff instead".
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