Interview Prep/Git & GitHub/Merge, rebase and cherry-pick

What does `git rebase --onto` do and when do you need it?

AdvancedConceptMerge, rebase and cherry-pick
Answer

It transplants a range of commits to a new base: git rebase --onto <newbase> <oldbase> <branch>. Typical use: you branched topic-b off topic-a, then topic-a was squash-merged, so you must move only topic-b's own commits onto main.

git rebase --onto main topic-a topic-b
All Git & GitHub questions Roadmap: Git & GitHub

More on Merge, rebase and cherry-pick