Each day you didn’t know about how to use git-cherry-pick is half a developer’s day. Kind of my feeling after this week has passed.
It allows to take one commit from another branch and add it to the current branch. A commit becomes like a patch file that you pass around and applies on another branch. You just do not need to create any files😉. For example while you implement a new feature and you run over a general bug and you want to have this fixed in more then only your current feature branch.
What you can do then is to commit the fix in your feature branch, note the commit’s SHA1-ID (or some of it’s beginning first chars) and with it you can apply it later on the stable branch with git-cherry-pick.
git cherry-pick SHA1-ID will commit the changes unless you make use of the -n switch, which will apply the changes but not commit them.
This done you can ensure that a fix is not lost in current “upstream” while you still can fiddle with your new feature. That’s nice.
And if someone else found a fix, you can naturally cherry-pick it as well into your current branch. How flexible!
Read On: git cherry-pick wins