This is the fifth and last video in the Git Animated series. If you are interested in the other ones, check the links below:

In this video we look at cherry-pick, a powerful Git command that lets you apply the changes introduced by a specific commit from one branch onto another, without merging or rebasing the entire branch. Think of it as picking a single commit — like a cherry — and grafting it onto a different branch.

In the animation, we start on master with commits M0 and M1, then create a feature branch and add three commits F0, F1, and F2 to it. We then switch back to master and add one more commit M2. At this point the two branches have diverged. Instead of merging or rebasing the whole feature branch, we cherry-pick only commit F1 onto master. Git takes the diff introduced by F1 and replays it on top of M2, producing a new commit that carries the same changes but has a different hash and a different parent.

Notice that the feature branch is left untouched, and commits F0 and F2 are not brought over — only F1 is. This is what makes cherry-pick so useful: you can selectively integrate individual commits across branches, for example to backport a bug fix to a release branch without pulling in unrelated work.

For your convenience, here are the Git commands which appear in the video:

git commit -m 'M0'
git commit -m 'M1'
git branch feature
git checkout feature
git commit -m 'F0'
git commit -m 'F1'
git commit -m 'F2'
git checkout master
git commit -m 'M2'
git cherry-pick F1

Here is the video(there is no audio):

Feel free to drop me a comment or e-mail with your constructive criticism. It will be much appreciated!

Enjoy!