p4 merge


Merge one set of files into another.


p4 [g-opts] merge [-c change] [-m max] [-n -Ob -q -F] [--from stream] [toFile[fromRevRange]]
p4 [g-opts] merge [-c change] [-m max] [-n -Ob -q] fromFile[fromRevRangetoFile


The p4 merge command is a simplified form of the p4 integrate command: it merges a set of changes from source to target files. The command outputs the scheduled resolves. This command is intended for use with streams and distributed version control, but is also perfectly usable for traditional Perforce branches.

Using the client workspace as a staging area, p4 merge schedules all affected target files to be resolved per changes in the source. Target files outside of the current client view are not affected. Source files need not be within the client view.

Each file in the target is mapped to a file in the source. Mapping adjusts automatically for files that have been moved or renamed, as long as p4 move was used to move or rename the files. The scope of source and target files sets must include both old-named and new-named files for mappings to be adjusted. Moved source files may schedule moves to be resolved in target files. You can limit the revisions to be merged using the fromRevRange parameter. If the scope does not include both old and new files, for example, if you run the merge on a single file that is either the move/add or move/delete of the move pair of actions, an error message is shown.

With streams, you use p4 merge to keep a child stream up to date with a more stable parent stream. This ensures that when you promote changes back to the stable parent, you do not inadvertently overwrite any other changes that were checked into the parent. Files are opened in a pending changelist and scheduled for resolve as required. To update the parent stream, resolve and submit. By default, p4 merge merges changes into the current stream from its parent, or from another stream specified by the --from option. The source and target can also be specified on the command line as a pair of file paths. More complex merge mappings can be specified using branch specifications as with p4 integrate. Use the -F option to force merging against a stream's expected flow. You can also use this option to force the generation of a branch view based on a virtual stream; the mapping itself refers to the underlying real stream.

In most cases, you can use the p4 merge and p4 copy commands to propagate changes between streams (or branches). The default behavior of p4 integrate is to schedule files for resolve by selecting the closest common ancestor as the base; p4 merge selects (as the base) the revision with the most edits in common with the source and target.

If you specify no arguments for the command, the target defaults to the current stream, and the source defaults to the current stream parent. You can specify a different source with --from stream_name, which is an alias for the -P option. You can specify the stream as a directory name relative to the current stream depot: for example, --from main instead of --from //Ace/main.


-c change

Specifies an existing pending changelist in which the files are to be opened.


Force merge operation; perform the operation when the target stream is not configured to accept a merge from the source. To determine a stream's expected flow of change, use p4 istat.

--from stream

Specifies a stream other than the parent stream to merge from.

-m max

Limits the number of files merged. This option is useful for scripts that integrate large number of files; it enables them to batch the integrations and minimize the locking-related impact to other users of the shared versioning service.


Preview the merge.


The -Ob option displays the base revision for the merge (if any) along with each scheduled resolve.


Quiet mode; suppresses normal output messages about the list of files being integrated, copied, or merged. Messages regarding errors or exceptional conditions are displayed.


See “Global Options”.

Usage Notes

Can File Arguments Use Revision Specifier?

Can File Arguments Use Revision Range?

Minimal Access Level Required





p4 merge -r -S //projectX/bruno_dev
p4 resolve
p4 submit -d "Update dev w latest changes"

Incorporate the latest changes from main (parent) into Bruno's development stream (child).

Related Commands

Promote changes to more stable neighbor stream

p4 copy

Propagate changes

p4 integrate

Resolve file conflicts

p4 resolve