Perforce 2006.1 Command Reference
<< Previous Chapter
p4 submit
Table of Contents
Index
Perforce on the Web
Next Chapter >>
p4 tag

p4 sync

Synopsis

Copy files from the depot into the workspace.

Syntax

p4 [g-opts] sync [-f] [-n] [-k] [file[revRange]...]

Description

p4 sync brings the client workspace into sync with the depot by copying files matching its file pattern arguments from the depot to the client workspace. When no file patterns are specified on the command line, p4 sync copies a particular depot file only if it meets all of the following criteria:

In new, empty, workspaces, all depot files meet the last two criteria, so all the files visible through the workspace view are copied into the user's workspace.

If file patterns are specified on the command line, only those files that match the file patterns and that meet the above criteria are copied.

If the file pattern contains a revision specifier, the specified revision is copied into the client workspace.

If the file argument includes a revision range, only files selected by the revision range are updated, and the highest revision in the range is used. Files that are no longer in the workspace view are not affected if the file argument includes a revision range.

The newly synced files are not available for editing until opened with p4 edit or p4 delete. Newly synced files are read-only; p4 edit and p4 delete make the files writable. Under normal circumstances, do not use your operating system's commands to make the files writable; instead, use Perforce to do this for you.

Options

-f

Force the sync. Perforce 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 flag does not affect open files, but it does override the noclobber client option.

-n

Display the results of the sync without actually performing the sync.

This lets you make sure that the sync does what you think it does before you do it.

-k

Keep existing workspace files; update the have list without updating the client workspace. Use p4 sync -k only when you need to update the have list to match the actual state of the client workspace.

g-opts

See the Global Options section.

Usage Notes

Can File Arguments Use
Revision Specifier?

Can File Arguments Use
Revision Range?

Minimal Access Level Required

Yes

Yes

read

By default, any empty directories in the client view are cleared of files, but the directories themselves are not deleted. To remove empty directories upon syncing, turn on the rmdir option in the p4 client form.

Examples

p4 sync

Copy the latest revision of all files from the depot to the client workspace, as mapped through the client view.

If the file is already open in the client workspace, or if the latest revision of the file exists in the client workspace, it is not copied.

p4 sync file.c#4

Copy the fourth revision of file.c to the client workspace, with the same exceptions as in the example above.

p4 sync //depot/proj1/[email protected]

Copy all the files under the //depot/proj1 directory from the depot to the client workspace, as mapped through the client view.

Don't copy the latest revision; use the revision of the file in the depot after changelist 21 was submitted.

p4 sync @labelname

If labelname is a label created with p4 label, and populated with p4 labelsync, bring the workspace into sync with the files and revision levels specified in labelname.

Files listed in labelname, but not in the workspace view, are not copied into the workspace.

Files not listed in labelname are deleted from the workspace. (That is, @labelname is assumed to apply to all revisions up to, and including, the revisions specified in labelname. This includes the nonexistent revision of the unlisted files.)

p4 sync @labelname,@labelname

Bring the workspace into sync with a label as with p4 sync @labelname, but preserve unlabeled files in the workspace.

(The revision range @labelname,@labelname applies only to the revisions specified in the label name itself, and excludes the nonexistent revision of the unlisted files.)

p4 sync @2001/06/24

Bring the workspace into sync with the depot as of midnight, June 24, 2001. (That is, include all changes made during June 23.)

p4 sync status%40june1st.txt

Sync a filename containing a Perforce wildcard by using the ASCII expression of the character's hexadecimal value. In this case, the file in the client workspace is [email protected].

For details, see "Limitations on characters in filenames and entities" on page 238.

p4 sync file.c#none

Sync to the nonexistent revision of file.c; the file is deleted from the workspace.

p4 sync ...#none

Sync to the nonexistent revision of all files; all files in the workspace (that are under Perforce control) are removed.

Related Commands

To open a file in a client workspace and list it in a changelist

p4 add
p4 edit
p4 delete
p4 integrate

To copy changes to files in the client workspace to the depot

p4 submit

To view a list of files and revisions that have been synced to the client workspace

p4 have


Perforce 2006.1 Command Reference
<< Previous Chapter
p4 submit
Table of Contents
Index
Perforce on the Web
Next Chapter >>
p4 tag
Please send comments and questions about this manual to [email protected].
Copyright 1999-2006 Perforce Software. All rights reserved.
Last updated: 06/23/06