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

P4 CLI Documentation | 2025.2

# 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 and naming 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

- 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.

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` uses to the `default` branch of the repo, such as main. 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:

- Including Graph Depot repos in your client in `p4 client`
- Working with depots of type graph in `p4 depot`
- Stream and graph depot - .git suffix and repo path in p4 stream

## Options

Option | Description
--- | ---
`-f` | Force the sync. P4 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. 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 syncs in p4 sync.

## Usage Notes

### Working with a depot of type graph

## Examples

`p4 sync dev` `p4 sync refs/heads/main` | For a repo in a depot of type `graph`, sync the branch named `dev` or `main`. 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`.

Your search for returned results