Git Cherry Pick Using Commit Hash
If you have one branch with a couple of commits and you want to pick one or some of them, the git cherry-pick command does it for you. It doesn't matter which one you want for example at the very beginning or end or in the nth position. You will not lose anything, there is no need to hard reset, revert or rebase. It's gonna be super simple.
Step 1. Checkout the branch you want to apply the commit (ex. master)?
git checkout master
Step 2. Run cherry pick command with your commit hash
git cherry-pick <commit-hash>
More useful cheery-pick commands
If you want to cherry-pick commit from A to B git cherry-pick A^..B
If you want to pick a couple of them from A, B, C, D, E, F?git cherry-pick A C F?
If you want to change the commit message when cherry-picking?git cherry-pick -e <commit-hash>?
If you want to keep an original commit reference?git cherry-pick -x <commit-hash>
If you have a conflict and you want to continue cherry-picking?git cherry-pick --continue?
Or if you want to skip the current commit and continue others?git cherry-pick --skip
If you don't want to resolve the conflict and abort the cherry-pick?git cherry-pick --abort?
If you want to allow commits with empty messages to be cherry-picked?git cherry-pick --allow-empty-message
Associate Manager(Software) at EBL
2 年good