git cherry-pick a single commit
📖 Scenario: You are working on a project with two branches: main and feature. A useful commit was made on the feature branch, and you want to copy that exact commit into the main branch without merging all changes.
🎯 Goal: Learn how to use git cherry-pick to copy a single commit from one branch to another.
📋 What You'll Learn
Create a
feature branch from mainMake a commit on
feature branch with exact message and contentSwitch back to
main branchUse
git cherry-pick with the commit hash from feature branchVerify the commit is applied on
main branch💡 Why This Matters
🌍 Real World
Cherry-picking is useful when you want to copy specific fixes or features from one branch to another without merging all changes. For example, applying a bug fix from a feature branch to the main production branch.
💼 Career
Understanding cherry-pick helps in managing code changes efficiently in team projects and production environments, a common task for developers and DevOps engineers.
Progress0 / 4 steps