I would like to append the commits of another branch to my current branch:
A---B---C feat_A*
/
o---o---o---o master
\
D---E---F feat_B
A---B---C---D'--E'--F' feat_A*
/
o---o---o---o master
\
D---E---F feat_B
However, doing a git rebase feat_B results in D---E---F---A'--B'--C'.
Another option would be to do
git checkout feat_B
git rebase feat_A
which results in the correct order A---B---C---D'--E'--F' but then these commits are in feat_B instead of feat_A.
How can I get git-rebase to append the commits of another branch onto the current one?
The operation could be easy without rebase, just cherry-pick the range you need :
git checkout feat_A
git cherry-pick ..feat_B
where ..feat_B is an implicit HEAD..feat_B, meaning "every commit from feat_B which is not already reachable from HEAD".
The git cherry-pick <commit> command allows you to take a single commit (from whatever branch) and, essentially, rebase it in your working branch.
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