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

P4 CLI Documentation | 2026.1

# Complex examples of command aliases

You can define aliases for complex commands by using redirection and special operators.

Before you can define an alias, you must create an alias file. See Define a command alias.

## Cherry picking

This alias definition:

    cherry-pick-change $(cl) $(s) $(t) = integrate //depot/$(s)/...@$(cl),$(cl) //depot/$(t)/...

turns the command:

    p4 cherry-pick-change 1015978 p15.2 main

into:

    p4 integrate //depot/p15.2/...@1015978,1015978   //depot/main/...

Another cherry picking example that creates a little merge script:

Copy

    cherry-pick $(cl) $(s) $(t) $(msg) = \
                   integrate //depot/$(s)/...@$(cl),$(cl) //depot/$(t)/... &amp;&amp;
                   resolve -am -Ac //depot/$(t)/... &amp;&amp;
                   submit -d $(msg) &amp;&amp;
                   sync

You could then execute a command like the following:

    p4 cherry-pick 1015978 two one "line a merged into one"

which would run the following commands:

    p4 integrate //depot/two/...@1015978,1015978 //depot/one/...
    p4 resolve -am -Ac //depot/one/...
    p4 submit -d "Cherry-pick change https://swarm.perforce.com/@1015978[1015978]
                  from //depot/two/... to //depot/one/..."
    p4 sync

## Simple pipelining

Starting with a simple example:

    newStreamsDepot $(dpt) = depot -o -t stream $(dpt) > $(depotSpec) &&
                             depot -i < $(depotSpec)

Note that when using redirection, the `$` variables used in the transformation side of the definition do not need to correspond to the arguments specified on the left side of the equation. In the example above, depotSpec is a variable created during the execution of the `newStreamDepot` alias.

Here are aliases for merge down copy up:

Copy

    mergedown $(b) = fetch &amp;&amp;
                     switch $(b) &amp;&amp;
                     merge &amp;&amp;
                     resolve -am &amp;&amp;
                     submit -d "Merged down from main"

    copyup $(b)    = switch dev &amp;&amp;
                     merge --from $(b) &amp;&amp;
                     resolve -as &amp;&amp;
                     submit -d "Copied up from $(b)" &amp;&amp;
                     push

    # Note the use of the branch name in the submit message of the copyup alias.

## DVCS: Aliases to communicate with multiple servers

Use aliases like the following when copying spec objects from the shared server to your personal server.

    copy-user $(p4port) = -p $(p4port) user -o $(u) > $(spec) &&
                        user -i < $(spec)

    copy-job $(p4port) $(j) = -p $(p4port) job -o $(j) > $(spec)  &&
                        job -i < $(spec)

    copy-stream $(p4port) $(s)  = -p $(p4port) stream -o $(s) > $(spec) &&
                        stream -i < $(spec)

Your search for returned results