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

P4 CLI Documentation | 2025.2

# Branching streams

To branch a stream, use the `p4 branch` command. When you branch a stream, P4 Server records the relationships between the branched files and their ancestors.

You can create branches using file specifications or branch specifications. For simple branches, use file specifications. For branches that are based on complex sets of files or to ensure that you have a record of the way you defined the branch, use branch specifications. Branch specifications can also be used in subsequent integrations. Branch specifications also can serve as a record of codeline policy.

## Using branch specifications

To map a set of files from source to target, you can create a branch mapping and use it as an argument when you issue the `p4 integrate` command. To create a branch mapping, issue the `p4 branch branchname` command and specify the desired mapping in the `View` field, with source files on the left and target files on the right. Make sure that the target files and directories are in your client view. Creating or altering a branch mapping has no effect on any files in the depot or client workspace. The branch mapping merely maps source files to target files.

To use the branch mapping to create a branch, issue the `p4 integrate -b branchname` command; then use `p4 submit` to submit the target files to the depot.

Branch specifications can contain multiple mappings and exclusionary mappings, just as client views can. For example, the following branch mapping branches the `Jam 1.0` source code, excluding test scripts, from the main codeline:

Copy

    Branch:   jamgraph-1.0-dev2release

    View:
        //depot/dev/main/jamgraph/...        //depot/release/jamgraph/1.0/...
        -//depot/dev/main/jamgraph/test/...  //depot/release/jamgraph/1.0/test/...
        //depot/dev/main/bin/glut32.dll      //depot/release/jamgraph/1.0/bin/glut32.dll

To create a branch using the preceding branch mapping, issue the following command:

    p4 integrate -b jamgraph-1.0-dev2release

and use `p4 submit` to submit the changes.

To delete a branch mapping, issue the `p4 branch -d branchname` command. Deleting a branch mapping has no effect on existing files or branches.

As with workspace views, if a filename or path in a branch view contains spaces, make sure to quote the path:

    //depot/dev/main/jamgraph/...    "//depot/release/Jamgraph 1.0/..."

Your search for returned results