Rebase Any String of Commits to a Target Commit<Branch> is optional and all it does is checks out the branch specified before executing the rest of the command. If you've already checked out the branch you want to rebase, then you don't need this.
You can avoid using the --onto parameter by making a temp branch on the commit you like and then use rebase in its simple form:
git branch temp master^
git checkout topic
git rebase temp
git branch -d temp
You can even take a direct approach:
git checkout topic
git rebase <commitB>
Use the "onto" option:
git rebase --onto master^ D^ D
The comment by jsz above saved me tons of pain, so here's a step-by-step recipie based on it that I've been using to rebase/move any commit on top of any other commit:
git rebase --onto <new parent> <old parent>
In the example above that's as simple as:
git checkout topic
git rebase --onto B A
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With