Helix Core is now P4. Product user interfaces will be updated soon. Learn more >>

P4 CLI Documentation | 2025.2

# p4 copy

Copy files and/or the stream spec from one location in the depot to another.

## Syntax

    p4 [g-opts] copy [-c change] [-n -f -K -v -q] [-m max] fromFile[rev] toFile
    p4 [g-opts] copy [-c change] [-n -f -K -v -q] [-m max] -b branch [-r] [toFile[rev] ...]
    p4 [g-opts] copy [-c change] [-n -f -K -v -q] [-m max] -b branch -s  fromFile[rev] [toFile ...]
    p4 [g-opts] copy [-c change] [-n -f -K -v -q] [-m max] -S stream [-P parent] [-Fr] [toFile[rev] ...]
    p4 [g-opts] copy [options] -S stream [-Af | -As] [-P parent] [-F] [-r] [toFile[rev] ...]

Syntax and naming conventions

## Description

Using the client workspace as a staging area, the `p4 copy` command propagates an exact copy of the source files to the specified target by branching, replacing, or deleting files. No manual resolve is required. Changes in the target that were not previously merged into the source are overwritten. To update the target, submit the files. To revert copied files, use the `p4 revert` command.

Target files that are identical to the source are not affected by the `p4 copy` command unless you use the `-f` option. When `p4 copy` creates or modifies files in the workspace, it leaves them read-only. You can use `p4 edit` to make them writable.

This command also works with openable stream specifications. p4 copy -S stream is described in the Options section.

In most cases, `p4 copy` command performs a lazy copy A method to conserve disk space by referencing files instead of duplicating their content.. The contents of the file are not duplicated on the server because the integration record contains sufficient information to reproduce the file.

## Options

Option | Description
--- | ---
`-b branch` | Specify a branch view to be used to determine source and target files.
`-c change` | Open the files in the specified pending changelist rather than in the default changelist.
`-f` | Force the creation of extra revisions in order to explicitly record that files have been copied. Deleted source files are copied if they do not exist in the target, and files that are already identical are copied if they are not connected by existing integration records.
`-F` | Force copy operation; perform the operation when the target stream is not configured to accept a copy of the source. To determine a stream’s expected flow of change, use `p4 istat`.
`-m max` | Specify the maximum number of files to copy, to limit the size of the operation.
`-K` | Suppress keyword expansion when updating +k type files on the client. See File type modifiers.
`-n` | Preview the copy.
`-P parent` | Specify a target stream other than the parent of the source stream. Requires `-S`.
`-q` | Quiet mode, which suppresses normal output messages about the list of files being integrated, copied, or merged. Messages regarding errors or exceptional conditions are displayed.
`-r [`toFile`[`rev`] ...]` | Reverse the mappings in the branch view, integrating from the target files to the source files. Requires the `-b` option.
`-s `fromFile`[`rev`] [`toFile` ...]` | Treat `fromFile` as the source and both sides of the branch view as the target. To restrict the scope of the target further, specify the optional `toFile` parameter. Overrides the `-r` option, if specified. Requires `-b`.
`-S stream` | Causes p4 copy to use a generated branch view that maps the stream to its parent and copy from a stream to its parent. To reverse the copy direction, use -r with -S. Copies the source stream spec propagatable fields into the target stream spec and opens for edit both the target stream spec and the stream files. However, you can specify:
-Af | -As
--- | ---
Copy the files only | Copy the stream spec only
Note that to submit copied stream files, the current client must be switched to the target stream or to a virtual child stream of the target stream.
`-v` | Performs a "virtual" integration that does not modify client workspace files unless target files need to be resolved. After submitting a "virtual integration", p4 sync can be used to update the workspace.
`g-opts` | See Global options.

## Usage notes

Can File Arguments Use Revision Specifier? | Can File Arguments Use Revision Range? | Minimal Access Level Required
--- | --- | ---
`fromFile`: Yes `toFile`: No | No | read access for fromFile open access for toFile

You can use a revision specifier to select the revision to copy; by default, the head revision is copied. The revision specifier can be used on `fromFile` or `toFile`, but not on both. When used on `toFile`, it refers to source revisions, not to target revisions. You cannot use a range as a revision specifier.

## Examples

`p4 copy -S //projectX/dev` | Create a stream quickly (without checking integration history)
p4 copy //projectX/dev/... //projectX/main/... | Promote work from a development stream to the mainline

## Related commands

Update a child stream with a more stable parent stream | `p4 merge`
Propagate changes after considering all integration history and scheduling resolves, if necessary | `p4 integrate`

Your search for returned results