>_ IzzyLab

Hands-on task

This task is step 3 of the course “Shipping a release”

Move a commit with cherry-pick

medium~7 min

In /root/project, the feature branch has a commit that adds the file hotfix.txt. Move only that commit into the main branch with cherry-pick (without merging the whole branch). hotfix.txt should appear in main.

What you'll practise:
  • git cherry-pick
  • git log
  • branches
  • moving commits

Topic breakdown

cherry-pick takes the changes of one specific commit and applies them on top of the current branch as a new commit — unlike merge, which pulls in the entire history of a branch. The mental model: first find the hash of the commit you need from the history (git log), then switch to the target branch and apply exactly that one. The key skill is not to catch neighboring commits of the branch, but to select precisely the one that carries the change you need.

What's checked

  1. current branch is main
  2. hotfix.txt moved into main
  3. feature-only.txt is absent from main
  4. main has a cherry-picked copy of the hotfix commit

What it looks like