Last Updated: February 25, 2016
·
1.968K
· stereoscott

Git cherry-pick

Want to grab just a few changes from another branch? Use "cherry-pick"!

It works like this. First get the ID of the commit containing the changes you want to grab from the other branch. In this case I want to the last committed change, so I'll use git log -1

git checkout some-other-branch
git log -1

Take note of the hash of the latest commit:

commit 7920e69909ba8777716511757de1ebed7dc2cc56
Author: Scott Meves
Date:   Wed Aug 22 10:47:37 2012 -0400

    fix typo on faqs

Let's merge that change over to master:

git checkout master
git cherry-pick 7920e69

That's it! You should see output similar to this:

[master 7920e69] typo on faqs
 1 file changed, 1 insertion(+), 1 deletion(-)

1 Response
Add your response

Great tip!!! thanks :-)

over 1 year ago ·