There are scenarios when we want to apply the changes of an earlier commit in a repo, on top of the current repo tree of some branch in the same repo. Or In some scenarios, we just want all the changes from an earlier commit of this repo into the current staging area and make some more changes before finally committing all the changes to the repo tree. For both scenarios, the git cherry-pick command comes in handy. Git documentation describes cherry-pick as git-cherry-pick — Apply the changes introduced by some existing commits. Given one or more existing commits, apply the change each one introduces, recording a new commit for each Let’s explain this with an example Step 1- Create a git repo mkdir git-example-cherry-pick && \ cd git-example-cherry-pick && \ git init Step 2- Add a few commits echo "First change" >> first.file && \ git add first.file && \ git commit -m "first commit" echo "Second change" ...
Explore more at my website