avp::ptr weblog

Everything that is in our mind.

Archive for the ‘cherry-pick’ tag

Git: How to copy a range of commits from one branch to another?

with 6 comments

Sometimes it is useful to copy a series of commit to another branch. This post describes how to do this using git rebase. Two example illustrate different scenarios which should help to understand the command arguments in generell.

Example 1: The commit P, Q, R which are contained in branch feature should be copied to branch master. The commits should be appended to commit M.

git rebase --onto M O R && git rebase HEAD master

The first command git rebase --onto M O R copies the commits P, Q, R to the branch master. They won’t be visible if you check the visual graph in gitk. This is because there is no branch reference that points to one of the three commits. To update the branch master run the second command git rebase HEAD master which moves up the HEAD to commit R.

Read the rest of this entry »

Written by tobi

September 28th, 2012 at 11:45 pm

Posted in Uncategorized

Tagged with , , , ,