I have two branches A and B in a project that I am working on. B differs from A by a single commit, which is a section of the code completely independent from what I'm working on for the next while (aka, I will have many commits I want to push to both branch A and B).
Is there any way in git that I can commit to both branch A and branch B at the same time, without having to commit it to one branch, checkout the other, and try to cherry pick out the commit(s).
the cherry-pick feature is a better way to do this, check answer at
Git: Commit to multiple branches at the same time
You could:
A
B
on top ofA
(if you haven't pushed B already, that is)That way,
B
will include all commits fromA
, plus its single commit.If you have shared
B
(pushed to a common remote repo), the idea is more to add any commit made onA
toB
(that is, "on top ofB
).The simplest way would be to merge
A
onB
, if you don't mind having only one commit onB
representing all commits fromA
.I would prefer that to any solution involving cherry-picking would mean different SHA1 for each commit recreated on
B
, which would make any future merge back toA
complicated (because Git would go back a long way to find a common ancestor)