Initialize a server and populate it with files

This approach is best when working collectively on an existing project; users work on a set of project files that are managed on a shared server.

To start this process, users invoke the p4 clone command to obtain from the shared server a copy of the files associated with the project. This is a convenient way to ensure that users receive the set of files they need to participate in the project.

The user can then work on these files and periodically push changes back to the shared server from which the files were cloned. They can also periodically fetch to get the latest changes made by others to the shared server files.

Run p4 clone

Here is the p4 clone command syntax:

p4 [-u user] [-d dir] [-c client] clone [-m depth] [-v] -p port -r remote
p4 [-u user] [-d dir] [-c client] clone [-m depth] [-v] -p port -f filespec

p4 clone includes a number of command-line arguments:

  • The -d option specifies the directory where you want to create the server’s files. If you don’t specify this option, the files are created in the current directory.
  • The -p option specifies the address of the shared server you wish to clone from.
  • The -m option performs a shallow fetch; only the last number of specified revisions of each file are fetched.
  • The -r option specifies the remote spec installed on the shared server to use as a template for the clone and stream setup. You can obtain the name of the desired remote from the shared server administrator or run the p4 remotes command against the shared server to obtain a list of candidates to choose from. At the time of cloning, Helix will copy the remote from the shared server to the personal server and name it origin. For more information on remotes, see “Understanding Remotes”.
  • The -f option specifies a filespec in the shared server to use as the path to clone; this path will also be used to determine the stream setup in the personal server. You can specify the -f option or the -r option but not both.
  • The -v option specifies verbose mode.
  • The -c option lets you customize the name of the stream that p4 clone creates.

Directories and files

The p4 clone command creates all the directories and files that the p4 init command creates. In addition, p4 clone creates a remote called origin on the personal server. A remote is a mapping of files on a local server to files on a shared server and is required for fetching, pushing, and cloning; it describes exactly which files should be copied from a local server to a shared server or vice-versa. It is described in detail in “Understanding Remotes”.

Get the latest changes

To update your personal server with the latest changes from the shared server, run p4 fetch. See “Fetching and Pushing” for more information.