Git Cherry Pick

One feature that comes in handy sometimes is the ability to cherry pick certain commits. You can select a particular commit from a branch and bring that into your own branch. This is a handy feature but one that should be used with care. Often a traditional merge works better, but sometimes you ONLY want to bring in one commit and not the rest of the branch. Say as part of a feature you discover a bug and commit that bug fix but it is a part of a larger feature. You would be able to cherry-pick only that bug fix commit and hotfix that into your remote environment.

# let's find the commit that we want to cherry pick
> git status
On branch feature-with-bugfix
> git log
commit a1d24225d21e3dd0bbafbac916b156e59a8b790e
Author: Khaliq Gant <khaliqgant@gmail.com>
Date:   Fri Jul 19 09:15:18 2019 +0200

    BUGFIX: change value passed into constructor
# let's switch to master to bring this commit into master
> git checkout master
# now we cherry pick that commit into master. We use the commit hash
> git cherry-pick a1d24225d21e3dd0bbafbac916b156e59a8b790e

Read more about it here

Instagram Post