p4 merge


Merge one set of files into another.


p4 [g-opts] merge [optionsfromFile[revRangetoFile
p4 [g-opts] merge [options] -b branch [-r] [toFile[revRange] ...]
p4 [g-opts] merge [options] -b branch -s fromFile[revRange] [toFile ...]
 p4 [g-opts] merge [options] -S stream [-P parent] [-F] [-r]
    [toFile[revRange] ...]

    options : -c change -n -Ooptions -m max -q


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

With streams, you use p4 merge to keep a child stream up to date with a more stable parent stream, to ensure 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.

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.


-c change

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


Preview the merge.

-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.

-b branch

Specifies a branch view to be used to determine source and target files.

-r [toFile[revRange] ...]

Reverses the mappings in the branch view, integrating from the target files to the source files. Requires the -b option.

-s fromFile[revRange] [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

Specifies the source stream. Files are merged to its parent stream. To merge from parent to child, specify the -r option, which reverses the direction.

-P parent

Merge to the specified parent stream. Overrides the parent defined in the source stream specification.


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.


The -Ob option outputs the base revision for the merge (if any).


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 the “Global Options” section.

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