How to cherry-pick a commit in Git
Cherry-picking allows you to apply specific commits from one branch to another without merging entire branches, useful for selective bug fixes and feature backports.
As the creator of CoreUI, a widely used open-source UI library, I’ve used cherry-picking extensively to backport bug fixes and apply specific features across multiple CoreUI versions and release branches.
From my experience, the most reliable approach is to use git cherry-pick with the target commit hash.
This method provides precise commit selection while maintaining clean branch history.
Use git cherry-pick with the commit hash to apply a specific commit to your current branch.
# Cherry-pick a single commit
git cherry-pick a1b2c3d
# Cherry-pick multiple commits
git cherry-pick a1b2c3d e4f5g6h
# Cherry-pick a range of commits
git cherry-pick a1b2c3d..e4f5g6h
# Cherry-pick with commit message editing
git cherry-pick --edit a1b2c3d
# Cherry-pick without committing (stage changes only)
git cherry-pick --no-commit a1b2c3d
# View commits to cherry-pick
git log --oneline feature-branch
The git cherry-pick command takes the changes from the specified commit and applies them as a new commit on your current branch. Use the full commit hash or abbreviated version to identify the target commit. Multiple commits can be cherry-picked in sequence, or use range notation with .. to pick consecutive commits. The --edit flag allows you to modify the commit message, while --no-commit stages the changes without creating a commit automatically.
This is the same cherry-picking workflow we use in CoreUI development for applying critical bug fixes across different release branches and maintaining version compatibility. Always test cherry-picked commits thoroughly, as they may behave differently in the new branch context due to different surrounding code or dependencies.



