Reputation: 2141
I have the following structure:
A-B-C-D (branch-C)
\ \
\ H (branch-A)
\
\-E-F-G (branch-B)
I would LIKE this:
A-B-C-D (branch-A and branch-C)
\
\
\
\-E-F-G-H (branch-B)
How do I do this?
Upvotes: 1
Views: 133
Reputation: 129654
Assuming you have branch-B checked out:
git cherry-pick branch-A
git push . branch-C:branch-A -f
You now have the option to delete either branch-A or branch-C - or just keep both.
Upvotes: 3
Reputation: 98509
git checkout branch-B
git cherry-pick branch-A # you could also specify H directly
Now you have H atop G.
git checkout branch-A
git reset --hard HEAD^ # you could also specify D directly
# HEAD is the current commit; HEAD^ is the previous one
Now you've removed H from the branch which contained A-B-C-D.
Note that this only has meaning if there's some branch ref pointing to H and G at the start, since a commit object in git incorporates it ancestors; "moving" a commit doesn't mean anything insofar as it changes your branches.
Upvotes: 1