For moving an individual from one branch to another I realize that there are a few options in git. I have experimented with git merge and git cherry-pick but am failing to see when git cherry-pick is preferable.
My understanding is the following:
git merge <hash> moves the specified commit from one branch to the other preserving it as one commit.
git cherry-pick <hash> creates a copy of the commit in the second branch but it is separate with its own commit hash.
The first option seems preferable to me but what are the instances when cherry-pick would be preferred?
Say you have a branch from
masterthat has a bunch of commits. Maybe you made a change that is appropriate onmaster, but you don’t want to bring in all of the changes (a small bug fix, for example, or the addition of a small feature). Withgit cherry-pick, you can grab only that commit from the other branch and bring it intomaster.