Git Cheat Sheet · Integrate

Take a commit from another branch

git cherry-pick <commit>

git cherry-pick <commit> applies the changes of a specific commit to your current branch, as a new commit. It is useful for carrying a fix over to a release branch without merging everything else.

What it does

Copies the changes of a specific commit onto the current branch.

A use case

A fix made on the development branch must also go on the release branch.

On the command line

git cherry-pick <commit>
Copies a commit.
git cherry-pick <a> <b> <c>
Copies several commits, in order.
git cherry-pick <a>^..<b>
Copies a series of commits, from a to b inclusive.
git cherry-pick -x <commit>
Adds a reference to the original commit to the message.
git cherry-pick --continue / --abort
Resumes after a conflict, or cancels.

In Merathon

  1. Switch to the receiving branch.
  2. Right-click the commit in the graph → "Cherry-pick into <branch>".

Frequently asked questions

Is the original commit moved?

No: it stays on its branch. Cherry-picking creates a copy, with a different identifier.

How do I cherry-pick a merge commit?

You must state the reference parent: git cherry-pick -m 1 <commit>.

See also