What happens when a conflict occurs during a rebase, and how do you continue?
Rebase stops at the commit that conflicts. You fix the files, git add them, and run git rebase --continue. You can skip that commit with --skip or give up entirely with --abort.
Explain it simply
Rebase replays your commits one at a time on a new base. If commit 3 touches lines that changed upstream, Git cannot apply it automatically and pauses, leaving you in the middle of the replay.
Status shows 'rebase in progress'. Open the marked files, resolve them, git add them, and run git rebase --continue. You do not run git commit yourself. Later commits may conflict again, since each is replayed separately. --abort returns you to the state before you started, which is the safe exit when things go wrong. A note on wording: during rebase, 'ours' is the branch being rebuilt on and 'theirs' is your commit.
Example
git rebase main
# CONFLICT (content): Merge conflict in cart.js
# edit cart.js, remove markers
git add cart.js
git rebase --continue
git rebase --abort # bail out to the original stateWhat to say in the interview
"The rebase pauses at the conflicting commit. I resolve the files, stage them, and run git rebase --continue, repeating if more commits conflict. If I get stuck, git rebase --abort restores the branch to how it was. Note that ours and theirs are swapped compared with a merge."
Common mistakes
- Running git commit instead of git rebase --continue.
- Forgetting that every replayed commit can conflict separately.