Interview Prep/Git & GitHub/Rebase, Cherry-pick and History Rewriting

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 →

  1. Remember: during rebase, "ours" is the branch being rebased onto (upstream), "theirs" is your commit being replayed.
  2. To keep your change: git checkout --theirs file.
  3. To keep upstream's version: git checkout --ours file.
  4. 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".

All Git & GitHub questions Roadmap: Git & GitHub

More on Rebase, Cherry-pick and History Rewriting