I have two branches. Commit a
is the head of one, while the other has b
, c
, d
, e
and f
on top of a
. I want to move c
, d
, e
and f
to first branch without commit b
. Using cherry pick it is easy: checkout first branch cherry-pick one by one c
to f
and rebase second branch onto first. But is there any way to cherry-pick all c
-f
in one command?
views:
1060answers:
4
+5
A:
git format-patch --full-index --binary --stdout range... | git am -3
pc1500
2009-11-04 01:08:16
+7
A:
The simplest way to do this is with the onto
option to rebase
. Suppose that the branch which current finishes at a
is called mybranch and this is the branch that you want to move c
-f
onto.
# checkout mybranch
git checkout mybranch
# reset it to f (currently includes a)
git reset --hard f
# rebase every commit after b and transplant it onto a
git rebase --onto a b
Charles Bailey
2009-11-04 08:13:13
tig
2009-11-04 16:30:36
+1
A:
Git 1.7.2 introduced the ability to cherrypick a range of commits. From the release note:
git cherry-pick" learned to pick a range of commits (e.g. "cherry-pick A..B" and "cherry-pick --stdin"), so did "git revert"; these do not support the nicer sequencing control "rebase [-i]" has, though.
Eric Darchis
2010-10-14 13:08:39