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-p
precedingP4PORT
is optional. If not specified,p4 clone
uses the shared server specified by theP4PORT
environment variable. See P4PORT meaning before and after a clone for a discussion of howP4PORT
has a different meaning before and after a clone. - 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 thep4 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 itorigin
. 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.It is optional to specify the `-f` string on the command line. Instead, you can simply follow *`p4 clone`* with _filespec_.
- The
-v
option specifies verbose mode. - The
-c
option lets you customize the name of the stream thatp4 clone
creates.
P4PORT meaning before and after a clone
When you clone from a shared server to create a personal server,
the P4PORT
argument you pass to the p4 clone
command specifies
the address of the shared server you wish to clone from. If you don’t
pass a P4PORT
value via the -p
option, Helix uses the value of
P4PORT
set in the current command environment to identify the address
of the shared server you wish to clone from.
After a clone, P4PORT
refers to the personal server’s P4PORT
setting
in its P4CONFIG
file.
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 personal
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 personal 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.