diff --git a/doc/topics/git/cherry_picking.md b/doc/topics/git/cherry_picking.md index fe7bd333f88a84d93546860fd444debb44bcd3f8..0fe77a4a0ed375b929adcf72202114693006c8d1 100644 --- a/doc/topics/git/cherry_picking.md +++ b/doc/topics/git/cherry_picking.md @@ -11,14 +11,13 @@ and apply those changes to another branch. Cherry-picks can help you: - Backport bug fixes from the default branch to previous release branches. - Copy changes from a fork - [to the upstream repository](../../user/project/merge_requests/cherry_pick_changes.md#cherry-pick-into-a-project). + [to the upstream repository](../../user/project/merge_requests/cherry_pick_changes.md). You can cherry-pick commits from the command line. In the GitLab user interface, -you can also: +you can also cherry-pick: -- Cherry-pick [all changes from a merge request](../../user/project/merge_requests/cherry_pick_changes.md#cherry-pick-all-changes-from-a-merge-request). -- Cherry-pick [a single commit](../../user/project/merge_requests/cherry_pick_changes.md#cherry-pick-a-single-commit). -- Cherry-pick [from a fork to the upstream repository](../../user/project/merge_requests/cherry_pick_changes.md#cherry-pick-into-a-project). +- [All changes from a merge request](../../user/project/merge_requests/cherry_pick_changes.md#cherry-pick-all-changes-from-a-merge-request) from the current project or a project fork. +- [A single commit](../../user/project/merge_requests/cherry_pick_changes.md#cherry-pick-a-single-commit). ## Cherry-pick from the command line diff --git a/doc/user/project/merge_requests/cherry_pick_changes.md b/doc/user/project/merge_requests/cherry_pick_changes.md index 7ac80c81911a0a58a6f1ae49c4b5edfca1654188..069e3cc5ebd46d7effc8c2a41b89966a3fe43e1f 100644 --- a/doc/user/project/merge_requests/cherry_pick_changes.md +++ b/doc/user/project/merge_requests/cherry_pick_changes.md @@ -6,23 +6,19 @@ info: To determine the technical writer assigned to the Stage/Group associated w # Cherry-pick changes **(FREE ALL)** +> Feature flag `pick_into_project` [removed](https://gitlab.com/gitlab-org/gitlab/-/issues/324154) in GitLab 14.0. + 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. You should cherry-pick a commit when you need the -change contained in a single commit, but you can't or don't want to pull the -entire contents of that branch into another. - -You can use the GitLab UI to cherry-pick single commits or entire merge requests. -You can even cherry-pick a commit from [a fork of your project](#cherry-pick-into-a-project). - -NOTE: -Support for tracking commits cherry-picked from the command line -is tracked [in this issue](https://gitlab.com/gitlab-org/gitlab/-/issues/202215). +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. -## Cherry-pick example +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 of cherry-picking, a Git repository has two branches: `develop` and `main`. -This example shows a cherry-picked commit from one branch being added to another: +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: ```mermaid gitGraph @@ -41,15 +37,15 @@ gitGraph commit id:"H" ``` -In this example, a cherry-pick of commit `B` from the `develop` branch is added -after commit `E` in the `main` branch. - -Commit `G` is added after the cherry-pick. +Commits cherry-picked from the command line +do not appear in the GitLab UI. For more information, +see [issue 202215](https://gitlab.com/gitlab-org/gitlab/-/issues/202215). ## 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. +by the merge request. The merge request can be in the upstream project or in +a downstream fork. Prerequisites: @@ -68,10 +64,10 @@ To do this: 1. On the left sidebar, select **Search or go to** and find your project. 1. Select **Code > Merge requests**, and find your merge request. 1. Scroll to the merge request reports section, and find the **Merged by** report. -1. In the upper-right corner, select **Cherry-pick**: +1. In the upper-right corner of the report, select **Cherry-pick**:  -1. In the modal window, select the project and branch to cherry-pick into. +1. On the dialog, select the project and branch to cherry-pick into. 1. Optional. Select **Start a new merge request with these changes**. 1. Select **Cherry-pick**. @@ -86,23 +82,8 @@ To cherry-pick a commit from the list of all commits for a project: 1. On the left sidebar, select **Search or go to** and find your project. 1. Select **Code > Commits**. 1. Select the [title](https://git-scm.com/docs/git-commit#_discussion) of the commit you want to cherry-pick. -1. In the upper-right corner, select **Options > Cherry-pick** to show the cherry-pick modal. -1. In the modal window, select the project and branch to cherry-pick into. -1. Optional. Select **Start a new merge request with these changes**. -1. Select **Cherry-pick**. - -### From a merge request - -You can cherry-pick commits from any merge request in your project, regardless of -whether the merge request is open or closed. To cherry-pick a commit from the -list of commits included in a merge request: - -1. On the left sidebar, select **Search or go to** and find your project. -1. Select **Code > Merge requests**, and find your merge request. -1. In the merge request's secondary menu, select **Commits** to display the commit details page. -1. Select the [title](https://git-scm.com/docs/git-commit#_discussion) of the commit you want to cherry-pick. -1. In the upper-right corner, select **Options > Cherry-pick** to show the cherry-pick modal. -1. In the modal window, select the project and branch to cherry-pick into. +1. In the upper-right corner, select **Options > Cherry-pick**. +1. On the cherry-pick dialog, select the project and branch to cherry-pick into. 1. Optional. Select **Start a new merge request with these changes**. 1. Select **Cherry-pick**. @@ -112,34 +93,19 @@ You can cherry-pick from the list of previous commits affecting an individual fi when you view that file in your project's Git repository: 1. On the left sidebar, select **Search or go to** and find your project. -1. Select **Code > Repository** and go to the file - changed by the commit. -1. Select **History**, then select the [title](https://git-scm.com/docs/git-commit#_discussion) +1. Select **Code > Repository**. +1. Go to the file changed by the commit. In the upper-right corner, select **History**. +1. Select the [title](https://git-scm.com/docs/git-commit#_discussion) of the commit you want to cherry-pick. -1. In the upper-right corner, select **Options > Cherry-pick** to show the cherry-pick modal. -1. In the modal window, select the project and branch to cherry-pick into. +1. In the upper-right corner, select **Options > Cherry-pick**. +1. On the cherry-pick dialog, select the project and branch to cherry-pick into. 1. Optional. Select **Start a new merge request with these changes**. 1. Select **Cherry-pick**. -## Cherry-pick into a project - -> - [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/21268) in GitLab 13.11 behind a [feature flag](../../feature_flags.md), disabled by default. -> - [Feature flag removed](https://gitlab.com/gitlab-org/gitlab/-/issues/324154) in GitLab 14.0. - -You can cherry-pick merge requests from the same project, or forks of the same -project, from the GitLab user interface: - -1. In the merge request's secondary menu, select **Commits** to display the commit details page. -1. In the upper-right corner, select **Options > Cherry-pick** to show the cherry-pick modal. -1. In **Pick into project** and **Pick into branch**, select the destination project and branch: -  -1. Optional. Select **Start a new merge request** if you're ready to create a merge request. -1. Select **Cherry-pick**. - ## 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](../system_notes.md) -to the related merge request thread in the format **{cherry-pick-commit}** +to the related merge request thread. The format is **{cherry-pick-commit}** `[USER]` **picked the changes into the branch** `[BRANCHNAME]` with commit** `[SHA]` `[DATE]`:  @@ -147,10 +113,11 @@ to the related merge request thread in the format **{cherry-pick-commit}** The system note crosslinks the new commit and the existing merge request. Each deployment's [list of associated merge requests](../../../api/deployments.md#list-of-merge-requests-associated-with-a-deployment) includes cherry-picked merge commits. +Commits cherry-picked outside the GitLab UI or API do not add a system note. + ## Related topics -- Use the [Commits API](../../../api/commits.md) to add custom messages - to changes when you use the API to cherry-pick. +- [Commits API](../../../api/commits.md) ## Troubleshooting diff --git a/doc/user/project/merge_requests/img/cherry_pick_into_project_v13_11.png b/doc/user/project/merge_requests/img/cherry_pick_into_project_v13_11.png deleted file mode 100644 index ada036255f27e198d4d003574aa42c06a71b8ee7..0000000000000000000000000000000000000000 Binary files a/doc/user/project/merge_requests/img/cherry_pick_into_project_v13_11.png and /dev/null differ