Mar 22, 2012

git cherry-picking


I recently read this awesome git tutorial, about what is going on inside git for a day-to-day workflow like checkout, reset, branching, HEAD, commit etc. And I found myself in the bellow situation, when I remembered what I learned. Here's the master branch:

git master branch log

And now, here's my old_dev branch, on which I have some unmerged commits:

git branch from which we cherry-pick

Suppose now that I only what the commit on which old_dev is pointing to (SHA d33957a). Where I to

$ git merge old_dev

from master branch, I would add commit 9fdd36a, which is "buggy" (as the commit message says), and I don't want that. Also, I may be required to resolve some merge conflicts manually. So to "pick" only a specific commit, one uses a cherry-pick from the branch where the commit is wanted to be applied:

$ git cherry-pick d33957a

Now the master branch only has the commit I wanted to add in the first place:

git master branch after cherry-pick

No comments:

Post a Comment