---
title: Copy
description: Copy a pull request to another branch.
---

The `copy` action enables you to automatically create a copy of a pull request.
When the conditions you specify are met, Mergify will create a new pull request
to merge the changes into the specified base branch.

:::note
  The `copy` action is equivalent to the
  [`backport`](/workflow/actions/backport) action. The only difference is that
  the `backport` action will only copy the original pull request once it is
  merged.
:::

Note that in case of a conflict during the copy, Mergify will create a pull
request with the conflict; you will have to resolve it manually. You can change
this behaviour using the `ignore_conflicts` option.

:::caution
  Please make sure the branches specified in the copy action exist and you have
  the necessary access permissions. If the branch does not exist or you don't
  have the required permissions, the action will fail.
:::

## Parameters

The `copy` action takes a list of branches to which the changes from the pull
request will be copied. The branch names should be specified as strings.

| Key name | Value type | Default | Description |
| --- | --- | --- | --- |
| `assignees` | list of template |  | Users to assign the newly created pull request to. As the type is a data type template, you could use, e.g., `{{author}}` to assign the pull request to its original author. |
| `body` | template | `"{{ body }}<hr>This is an automatic copy of pull request #{{number}} done by [Mergify](https://mergify.com).
"` | The pull request's body. |
| `bot_account` | template or null | `null` | Mergify can impersonate a GitHub user to copy a pull request. If no `bot_account` is set, Mergify copies the pull request itself. |
| `branches` | list of Branch Name |  | The list of branches the pull request should be copied to. |
| `ignore_conflicts` | boolean | `true` | Whether to create the pull requests even if there are conflicts when cherry-picking the commits. |
| `label_conflicts` | string | `"conflicts"` | The label to add to the created pull request if it has conflicts and `ignore_conflicts` is set to `true`. |
| `labels` | list of string |  | The list of labels to add to the created pull requests. |
| `merge_conflict_style` | `merge` or `diff3` | `"merge"` | Style used by git when displaying merge conflicts |
| `regexes` | list of regex |  | The list of regexes to find branches the pull request should be copied to. |
| `report_mode` | list of `check` or `comment` | `["check"]` | Reporting modes for the action's result. Check will create a check on the pull request, and comment will post a comment on the pull request. |
| `title` | template | `"{{ title }} (copy #{{ number }})"` | The pull request's title. |

As the title and body are templates, you can leverage any pull request
attributes to use as content, e.g., `{{author}}`.

Note that the `commits` attribute here will be the list of cherry
picked commits.

On top of that, you can also use the following additional variables:

- `{{ destination_branch }}`: the name of the destination branch.

- `{{ cherry_pick_error }}`: the cherry pick error message if any (only
    available in body).

## Examples

### Using Labels to Copy

Below is an example of how to use the `copy` action:

```yaml
pull_request_rules:
  - name: copy patches to the prod branch
    conditions:
      - label = copy-to-prod
    actions:
      copy:
        branches:
          - prod
```
