Cherry-pick changes

  • Tier: Free, Premium, Ultimate
  • Offering: GitLab.com, GitLab Self-Managed, GitLab Dedicated

In Git, cherry-picking is taking a single commit from one branch and adding it as the latest commit on another branch. The rest of the commits in the source branch are not added to the target. Cherry-pick a commit when you need the contents in a single commit, but not the contents of the entire branch. For example, when you:

  • Backport bug fixes from the default branch to previous release branches.
  • Copy changes from a fork to the upstream repository.

Use the GitLab UI to cherry-pick a single commit or the contents of an entire merge request from a project or a project fork.

In this example, a Git repository has two branches: develop and main. Commit B is cherry-picked from the develop branch after commit E in the main branch. Commit G is added after the cherry-pick:

%%{init: { "fontFamily": "GitLab Sans" }}%%
gitGraph
    accTitle: Example of cherry-picking a commit
    accDescr: Commit B is copied from the develop branch to the main branch while leaving the original branch unchanged.

 commit id: "A"
 branch develop
 commit id:"B"
 checkout main
 commit id:"C"
 checkout develop
 commit id:"D"
 checkout main
 commit id:"E"
 cherry-pick id:"B"
 commit id:"G"
 checkout develop
 commit id:"H"

View system notes for cherry-picked commits

When you cherry-pick a merge commit in the GitLab UI or API, GitLab adds a system note to the related merge request thread.

System notes are only created when cherry-picking merge commits. System notes are not created when using fast-forward merge. This applies to both cherry-picking individual commits and cherry-picking all changes from a merge request.

Commits cherry-picked outside the GitLab UI or API also do not create system notes.

When a system note is created, the format is cherry-pick-commit [USER] picked the changes into the branch [BRANCHNAME] with commit [SHA] [DATE]:

Cherry-pick tracking in merge request timeline

The system note crosslinks the new commit and the existing merge request. Each deployment’s list of associated merge requests includes cherry-picked merge commits.

Cherry-pick all changes from a merge request

After a merge request is merged, you can cherry-pick all changes introduced by the merge request. The merge request can be in the upstream project or in a downstream fork.

Prerequisites:

  • You must have a role for the project that allows you to edit merge requests and add code to the repository.

  • Your project must use the merge commit method, which is set in the project’s Settings > Merge requests.

    Fast-forwarded commits can be cherry-picked from the GitLab UI only when they are squashed or when the merge request contains a single commit. You can always cherry-pick individual commits.

    System notes are not created when using the fast-forward merge method.

To do this:

  1. In the top bar, select Search or go to and find your project.

  2. In the left sidebar, select Code > Merge requests, and find your merge request.

  3. Scroll to the merge request reports section, and find the Merged by report.

  4. In the upper-right corner of the report, select Cherry-pick:

    Cherry-pick merge request

  5. On the dialog, select the project and branch to cherry-pick into.

  6. Optional. Select Start a new merge request with these changes.

  7. Optional. Select Copy merge request description to start the new merge request from the description of the merge request you cherry-pick, instead of from the description templates. Available only when you start a new merge request.

  8. Select Cherry-pick.

Cherry-pick a single commit

You can cherry-pick a single commit from multiple locations in your GitLab project.

If you cherry-pick a merge commit, GitLab creates a system note in the related merge request to track the operation.

From a project’s commit list

To cherry-pick a commit from the list of all commits for a project:

  1. In the top bar, select Search or go to and find your project.
  2. In the left sidebar, select Code > Commits.
  3. Select the title of the commit you want to cherry-pick.
  4. In the upper-right corner, select Options > Cherry-pick.
  5. On the cherry-pick dialog, select the project and branch to cherry-pick into.
  6. Optional. Select Start a new merge request with these changes.
  7. Select Cherry-pick.

From the file view of a repository

You can cherry-pick from the list of previous commits affecting an individual file when you view that file in your project’s Git repository:

  1. In the top bar, select Search or go to and find your project.
  2. In the left sidebar, select Code > Repository.
  3. Go to the file changed by the commit. In the last commit block, select History.
  4. Select the title of the commit you want to cherry-pick.
  5. In the upper-right corner, select Options > Cherry-pick.
  6. On the cherry-pick dialog, select the project and branch to cherry-pick into.
  7. Optional. Select Start a new merge request with these changes.
  8. Select Cherry-pick.

Select a different parent commit

When you cherry-pick a merge commit in the GitLab UI, the mainline is always the first parent. Use the command line to cherry-pick with a different mainline. For more information, see copy the contents of an entire branch.

Troubleshooting

When working with cherry-picks in the GitLab UI, you might encounter the following issues.

Error: These changes conflict with changes on <branch>

When you cherry-pick a merge request or commit, you might get an error that states:

Merge request cherry-pick failed: These changes conflict with changes on <branch>. Cherry-pick locally to resolve the conflicts.

This issue occurs when the branch you cherry-pick into has changed the same lines as the changes you cherry-pick. A merge request checks for conflicts only against its own target branch. The merge request can show no conflicts and still fail to cherry-pick into another branch.

The GitLab UI cannot resolve cherry-pick conflicts. To resolve this issue, cherry-pick the changes on the command line and resolve the conflicts there. For more information, see apply one commit to another branch.

Error: There is nothing to cherry-pick into <branch>

When you cherry-pick a merge request or commit, you might get an error that states:

Merge request cherry-pick failed: There is nothing to cherry-pick into <branch>.

This issue occurs when the cherry-pick would not change the branch. For example:

  • The branch already contains the changes, because they were cherry-picked or merged before. No action is needed.
  • The merge commit of the merge request contains no changes. This happens when the changes reached the target branch in another commit before the merge request merged. To copy the changes to another branch, cherry-pick the original commits instead.