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
More on Merge, rebase and cherry-pick
What is the difference between a fast-forward merge and a merge commit?BeginnerHow does a three-way merge work?IntermediateWhat does `git rebase` actually do?IntermediateMerge versus rebase: how do you decide?IntermediateWhat are squash merge, merge commit and rebase-and-merge on GitHub?IntermediateWhy does a squash-merged branch show as unmerged to `git branch --merged`?Intermediate