Skip to main content
March 23, 2026/3 min read

Cherry Picking: git cherry-pick

Master Git Cherry-Pick for Selective Commit Management

What is Git Cherry-Pick?

Cherry-picking allows you to select specific commits from one branch and apply them to another, giving you granular control over which changes to integrate without merging entire branches.

Cherry Pick a Commit from a Different Branch

  1. In your terminal (Terminal, Git Bash, or Windows Command Prompt), navigate to the directory containing your Git repository. This foundational step ensures you're working in the correct project context before executing any Git operations.
  2. Check out the target branch where you want to apply the cherry-picked commit—not the source branch containing the original commit. Enter this command, replacing master with your desired branch name if different:
    • git checkout master
    Note: Many organizations have transitioned from "master" to "main" as the default branch name in 2026, so adjust accordingly based on your repository's naming convention.
  3. Every commit in Git has a unique SHA-1 hash identifier (typically displayed as a shortened 7-character string like 2f5451f). You'll need to locate the exact hash of the commit you want to cherry-pick. Here are the two most reliable methods to find commit hashes:
    • Browse the commit history directly on your repository hosting platform (GitHub, GitLab, Bitbucket, or Azure DevOps).
    • Execute the following command in your terminal to view a condensed commit log: git log --oneline
    The --oneline flag provides a clean, readable format showing each commit's hash alongside its message, making it easier to identify the specific commit you need.
  4. Once you've identified the target commit hash, execute the cherry-pick command, substituting 2f5451f with your actual commit hash:
    • git cherry-pick 2f5451f
    Git will attempt to apply the changes from that specific commit to your current branch. If conflicts arise, Git will pause the process and prompt you to resolve them manually before completing the cherry-pick operation.
Cherry Pick Multiple Commits

For complex feature migrations or when you need to apply several related commits, you can cherry-pick multiple commits in a single operation. List the commit hashes in chronological order (the sequence they were originally committed) to maintain logical code progression and minimize merge conflicts.

git cherry-pick hash1 hash5 hash7

This approach is particularly valuable when backporting bug fixes or selectively applying features from a development branch to a production release branch.

Git Cherry-Pick Workflow

1

Navigate to Repository

Open your terminal and navigate to your Git repository folder using Terminal, Git Bash, or Windows Command Prompt.

2

Checkout Target Branch

Switch to the branch where you want to apply the commit using 'git checkout master' or your desired branch name.

3

Find Commit Hash

Locate the unique commit hash from GitHub/Bitbucket interface or use 'git log --oneline' in your terminal.

4

Execute Cherry-Pick

Run 'git cherry-pick [hash]' replacing the hash with your specific commit identifier like '2f5451f'.

Methods to Find Commit Hash

Web Interface

View commit history directly on GitHub, Bitbucket, or your Git hosting platform's website interface. Each commit displays its unique hash identifier.

Terminal Command

Use 'git log --oneline' command in your terminal to see a condensed list of commits with their hash values and commit messages.

Cherry-Pick Multiple Commits

You can cherry-pick multiple commits simultaneously by listing their hashes in chronological order: 'git cherry-pick hash1 hash5 hash7'. This maintains the original commit sequence.

Go Beyond Git

Mastering Git is just one component of becoming a proficient developer in today's technology landscape. Whether you're looking to advance your current career or transition into tech, our comprehensive programming education programs are designed for working professionals who demand practical, industry-relevant training.

Our expert-led courses combine theoretical foundations with hands-on project work, ensuring you build portfolio-worthy applications while learning. Each program includes detailed workbooks, real-world case studies, and mentorship from seasoned industry professionals. Explore our current offerings:

Available NYC Programming Courses

Web Development

Comprehensive hands-on courses covering modern web development technologies with real-world applications and step-by-step workbooks for practical learning.

Python Programming

Master Python programming through interactive exercises and practical projects designed for students at all experience levels from beginner to advanced.

Data Science

Learn data analysis, visualization, and machine learning techniques through hands-on training with industry-standard tools and real datasets.

Web Design

Develop design skills and user experience expertise through practical projects that combine aesthetic principles with technical implementation.

Hands-On Learning Approach

Pros
Interactive exercises with real-world applications
Step-by-step workbooks for guided learning
Suitable for all experience levels
Multiple specialized course tracks available
Practical bootcamp format for intensive learning
Cons
Location-specific to NYC area
May require significant time commitment
Bootcamp intensity might not suit all learning styles

Key Takeaways

1Git cherry-pick allows selective application of specific commits from one branch to another without merging entire branches
2Always checkout the target branch first before executing the cherry-pick command to ensure commits are applied to the correct location
3Commit hashes can be found through web interfaces like GitHub/Bitbucket or using the 'git log --oneline' terminal command
4Multiple commits can be cherry-picked simultaneously by listing their hashes in chronological order within a single command
5Each commit has a unique hash identifier that looks like '2f5451f' and serves as the reference for cherry-pick operations
6Professional development requires continuous learning beyond basic Git operations through structured courses and hands-on practice
7Real-world applications and step-by-step guidance are essential components of effective programming education
8Cherry-picking is particularly useful for applying bug fixes or specific features across different development branches

RELATED ARTICLES