Git & GitHub Mastery: Workflows & CI/CD
Back to Real-World Git Workflows

Stash, Cherry-pick, Reset

Three utility commands for common situations: temporary save (stash), copy a specific commit (cherry-pick), move pointers (reset). FIND_VIDEO: search 'git stash cherry-pick reset tutorial' — recommended channel: Atlassian / Fireship. Aim for 10 min or under.

7 minutesVideo LessonPDF notes
🎯 Free Guest Mode: You are learning for free. Sign in to save your completion progress and quiz answers.
Loading progress...

Key moments

  1. Defining Cherry-Pick — Cherry-pick applies changes from a single existing commit onto a different branch, unlike merge or rebase.
  2. Identifying Target Hash — Locating the unique commit identifier using `git log [branch name] --oneline` is required before transfer.
  3. Executing Single Transfer — Check out the destination branch and run `git cherry-pick [hash]` to create a new commit.
  4. Executing Multiple Transfers — Multiple hashes can be listed in a single command, applying the changes sequentially in the specified order.
  5. Handling Merge Conflicts — If changes overlap, the process halts, requiring manual conflict resolution before continuing the operation.
  6. Immutability Principle — Cherry-pick always creates a brand new commit object with a unique hash on the destination branch.
PDF notes

Frequently asked questions

Why does cherry-pick create a new commit hash?

The new commit is created on a different branch with a different parent history, making it a unique object. It only replicates the content changes (the patch) of the original commit.

When should I use cherry-pick instead of merge?

Use cherry-pick when you need to grab an urgent, isolated change (like a hotfix) from a feature branch that is otherwise incomplete or unstable. Merge is for integrating the entire feature.

What happens if I cherry-pick a commit that has already been merged?

Git will likely apply the changes successfully but will result in duplicate content changes in your history, which can complicate future merges. Use caution to avoid duplication.

Can I cherry-pick a range of commits?

Yes, you can specify a range using `git cherry-pick A..B`, but `git rebase` is generally the safer and more idiomatic tool for transferring a continuous range of commits.

How was this lesson?

Your feedback helps us refine explanations and catch bugs.