Specify what to copy
As described in “Understanding Remotes”, you typically specify which files will be
pushed or fetched by listing depot paths in the DepotMap
field of the remote
spec. You can further narrow the set of files to be fetched or pushed with one
of two command-line arguments: one specifying a filespec pattern and the other
specifying a stream (with the -S
option).
If a filespec or stream name is provided, and the remote spec uses differing patterns for the local and remote sides of the DepotMap, the filespec argument or stream name must specify the files using the local server’s depot syntax. Note that the filespec must always be provided using depot syntax, not client syntax nor filesystem syntax. For more information, see “Understanding Remotes”.
-
To specify a remote you pass the
-r
option and the name of the remote to thep4 fetch
orp4 push
command. If-r
is not specified, the default is-r origin
:$ p4 fetch -r markm-remote
-
To specify a filespec you pass a filespec pattern to the
p4 fetch
orp4 push
command.$ p4 fetch //depot/projectx/...
-
To specify a stream you pass the
-S
option to thep4 fetch
orp4 push
command. Note that the stream must be listed in a depot mapping in your remote spec.$ p4 fetch -S //stream/dev
where
dev
is the name of the stream on your local server
Note that when you specify a filespec or a stream, the Helix Versioning Engine cannot use the performance optimization provided by the remote spec.
Unlike other versioning engines such as Git, you do not have to fetch or push the entire contents of the remote server’s repository; rather, you can fetch or push whatever subset of the repository you like. You specify this subset in the remote spec or at the command line of the fetch or push command.
Fetch a limited subset of history
If you have a server with a lot of history you may only want to fetch the latest
few revisions to save on local storage. To do so, use the -m N
option:
$ p4 fetch -m 5
This specifies that the server perform a shallow fetch, fetching only the last 5 revisions of each file. You can also take a slice of your history as noted above.