Use git cherry pick

To demonstrate how to use git cherry-pick let us assume we have a repository with the following branch state:

    a - b - c - d   Main
         \
           e - f - g Feature

git cherry-pick usage is straight forward and can be executed like:

git cherry-pick commitSha

In this example commitSha is a commit reference. You can find a commit reference by using git log. In this example we have constructed lets say we wanted to use commit `f` in main. First we ensure that we are working on the main branch.

git checkout main

Then we execute the cherry-pick with the following command:

git cherry-pick f

Once executed our Git history will look like:

    a - b - c - d - f   Main
         \
           e - f - g Feature

The f commit has been successfully picked into the main branch.

Last updated