Sync files

Syncing—with the p4 sync command—adds, updates, or deletes files in the client workspace to bring the workspace contents into agreement with the depot. If a file exists within a particular subdirectory in the depot, but that directory does not exist in the client workspace, the directory is created in the client workspace when you sync the file. If a file has been deleted from the depot, p4 sync deletes it from the client workspace.

Example   Sync files from the depot to a client workspace

The command below retrieves the most recent revisions of all files in the client view from the depot into the workspace. As files are synced, they are listed in the command output.

C:\bruno_ws> p4 sync
//Acme/dev/bin/bin.linux24x86/readme.txt#1 - added as c:\bruno_ws\dev\bin\bin.linux24x86\readme.txt
//Acme/dev/bin/bin.ntx86/glut32.dll#1 - added as c:\bruno_ws\dev\bin\bin.ntx86\glut32.dll
//Acme/dev//bin/bin.ntx86/jamgraph.exe#2 - added as c:\bruno_ws\dev\bin\bin.ntx86\jamgraph.exe
[...]
Note

You cannot sync files that are not in your workspace view. See Configure workspace views for more information.

To sync revisions of files prior to the latest revision in the depot, use revision specifiers. For example, to sync the first revision of Jamfile, which has multiple revisions, issue the following command:

$ p4 sync //Acme/dev/jam/Jamfile#1

To sync groups of files or entire directories, use wildcards. For example, to sync everything in and below the jam folder, issue the following command:

$ p4 sync //Acme/dev/jam/...

The Helix Server tracks which revisions you have synced. For maximum efficiency, Helix Server does not re-sync an already-synced file revision. To re-sync files you (perhaps inadvertently) deleted manually, specify the -f option when you issue the p4 sync command.