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

P4 CLI Documentation | 2025.2

# Populate the mainline stream

Users of a non-stream classic depot A repository of P4 files that is not streams-based. Uses the Perforce file revision model, not the graph model. The default depot name is depot. See also 'stream depot' and 'graph depot'. populate a branch. See Codeline management.

There are two ways to populate a mainline stream:

- Add files from the local filesystem. It does not preserve file history and is the most typical way.
- Branch from other depots. If you have existing non-stream classic depots and you need to preserve file history, use this way.

## Add files

If you do not need to preserve file history, add the files. To add files to the mainline stream:

1. Create the workspace root directory if it does not exist.

   For example:

       C:\bruno_ws> cd C:\Users\bruno\p4clients
       C:\Users\bruno\p4clients> mkdir bruno_projectX_main

2. Copy the files and folders to the workspace root directory.

3. Change into the client workspace root directory, and use the `p4 reconcile` command to detect files not under P4 Server control and open them for add by using the p4 add command.

       C:\Users\bruno\p4clients> cd bruno_projectX_main
       C:\Users\bruno\p4clients\bruno_projectX_main> p4 add ...

To verify that the files are set up to be added correctly, issue the `p4 opened` command.

To populate the stream, submit the changelist in which the files are open.

For details on working with changelists, see Changelist-related tasks.

## Branch from other depots

You can branch files from other stream depots, classic depots, or remote depots into a stream. If you populate the mainline by branching, P4 Server preserves the connection between the revision history of the source and target files. Your workspace must be set to one associated with the target stream (example: `p4 set P4CLIENT=bruno_projectX_main`).

To populate the mainline by branching, issue the `p4 copy` command, specifying source and target. Example:

    p4 copy -v //mysourcedepot/mainline/... //ProjectX/main/...

In this example, the `-v` option performs the copy on the server without syncing the newly-created files to the workspace. This can be a significant time-saver if there are many files being copied. You can then sync only the files you intend to work with from the new location.

p4d displays a series of “import from” messages listing the source and target files, and opens the file(s) in a pending changelist. To preview the results of the operation without opening files, specify the `-n` option.

To populate the stream with the files from the mainline, issue the following commands:

1. To verify that the files are set up to be added correctly, issue the `p4 opened` command.
2. To populate the stream, `p4 submit` the changelist in which the files are open.

If you are populating an empty stream, you can simplify this process by using `p4 populate`. For example:

    p4 populate //mysourcedepot/mainline/...  //ProjectX/main/...

does the same thing as `p4 copy -v` followed by a `p4 submit`.

To preview what the result of the command would be, first use `p4 populate -n`, and, if the result is what you want, use `p4 populate` without the -n preview.

To undo an erroneous copy operation, issue the `p4 revert` command. For example:

    p4 revert //ProjectX/main/...

Your search for returned results