🎓 A1Learner
🔍
0 of 50 lessons completed

Cherry-Pick a Commit

Cherry-pick copies one snapshot onto your branch. It takes a single change without taking the whole branch.

Copy one snapshot

The honey snapshot moves from the experiment branch onto main.

$ git cherry-pick 6db1664

The change is on main now

The honey snapshot sits at the top, with a new hash.

$ git log --oneline

Example

$ git cherry-pick 6db1664
$ git log --oneline

Key points

  • Cherry-pick with a hash copies that snapshot.
  • The copy keeps the message and the author. It gets a new hash.
  • Use it to take a fix from another branch.
  • The other branch keeps its own copy too.
  • Picking the same change twice can confuse a later merge, so pick sparingly.

Here, one snapshot is copied onto main. The copy keeps the message and the date, and it gets the new hash 2ef148c.

Try it Yourself

Edit the code, then press Run.

Running is simulated

Exercise

What does cherry-pick copy?