p4 sync (graph)

Synchronize the client workspace with its view of the repo.

Syntax

p4 sync [-f -n -q -k] [--parallel=threads=N[,batch=N]] [file[commit-sha1 | reference] ...]

Syntax conventions

Description

Sync updates the client workspace to reflect the current contents of the repo (if it has changed).

If a filepath is specified and it matches paths that exist in one or more repos mapped to the client, those repos will be synced. For example,

  • If both repo1 and repo2 have a branch named dev,
    • the command p4 sync -f dev will sync the dev branch in both repos
    • the command p4 sync -f //repo/repo1/...@dev will sync the dev branch in repo1 and will not sync the dev branch from repo2
  • If only repo1 has a branch named dev,

    • the command p4 sync -f dev will sync the dev branch in repo1
    • the command p4 sync -f //repo/repo1/...@dev will sync the dev branch in repo1
Note
  • By default, the entire portion of the repo that is mapped to the client will be synced, not just the files in the specified filepath. If a sha or reference is specified, the client will be syned to that commit.
  • If a branch reference is specified, the branch with which the client is currently associated will also be updated.

If the client has open files in the specified repo, syncing will only be permitted if the commit that is to be synced is a child of the current commit (a fast-forward).

Sync adds files that have not been retrieved before, deletes previously retrieved files that have been deleted from the repo, and updates files that have been updated in the repo.

Normally, sync does not overwrite workspace files that the user has manually made writable. Setting the clobber option in the client specification disables this safety check.

Note

You can sync a client that has a view spec that maps files in a repo. If you do not specify a branch in the repo, p4 sync defaults to the master branch of the repo. If the client spec maps both a classic depot and a depot of type graph, p4 sync updates the client workspace for both types of depots. To sync a repo branch or a SHA-1, see the Examples.

For more information about depots of type graph, see:

Options

-f

Force the sync. Helix Server performs the sync even if the client workspace already has the file at the specified revision. If the file is writable, it is overwritten.

This option does not affect open files, but it does override the noclobber client option (see p4 client).

-k

Updates server metadata without syncing files. This enables you to ensure that the server reflects the state of files in the workspace while avoiding a large data transfer.

Warning

An erroneous update can cause the server to incorrectly reflect the state of the workspace.

-n

Preview mode: Display the results of the sync without actually performing the sync.

-q

Quiet operation: suppress normal output messages. Messages describing errors or exceptional conditions are not suppressed.

--parallel

Specify options for parallel file transfer. The configurable net.parallel.max must be set to a value greater than 1 to enable the --parallel option.

  • threads=n sends files concurrently using n independent network connections. The specified number of threads grab work in batches. There is no default value.

  • batch=n specifies the number of files in a batch.

    Default value is 8.

See Parallel processing in p4 sync.

Usage Notes

Working with a depot of type graph

Examples

p4 sync dev

p4 sync refs/heads/master

For a repo in a depot of type graph, sync the branch named dev or master. Both syntax styles are supported.

p4 sync c2ae39f

For a repo in a depot of type graph, sync the Git commit associated with the SHA-1 hash key c2ae39f4.

p4 sync refs/tags/v1.8.5-rc3

For a repo in a depot of type graph, sync the repo associated with a tag, such as v1.8.5-rc3.