You can use a serial combination of git rebase
and git branch
to apply a group of commits onto another branch. As already posted by wolfc the first command actually copies the commits. However, the change is not visible until you add a branch name to the top most commit of the group.
Please open the picture in a new tab ...
To summarize the commands in text form:
gitk --all &
.git rebase --onto a b f
.HEAD
is marked.git branch selection
This should clarify things:
a
is the new root destination of the group.b
is the commit before the first commit of the group (exclusive).f
is the last commit of the group (inclusive).Afterwards, you could use git checkout feature && git reset --hard b
to delete the commits c
till f
from the feature
branch.
In addition to this answer, I wrote a blog post which describes the commands in another scenario which should help to generally use it.