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 6db1664The change is on main now
The honey snapshot sits at the top, with a new hash.
$ git log --onelineExample
$ git cherry-pick 6db1664
$ git log --onelineKey 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?