Syncing a file or directory in your workspace may seem relatively straightforward, however there are a lot of complexities that you may not be aware of. Here is the most common form of syncing.
p4 sync filename<@CL>|
p4 sync directory\...<@CL>
By default (without "@version"), it will display the head version, like this:
p4 sync filename#head|
p4 sync directory\...#head
Or you can sync to a particular CL like this:
p4 sync filename@1234567|
p4 sync directory\...@1234567
As you probably know, syncing to a large directory can take a lot of time. So instead of syncing the entire directory with a single command, you can split the syncing of a directory up into multiple sync commands. For instance, if the parent directory that you want to sync only has 3 children sub-directories that are each large, then it will be MUCH faster to sync all three children sub-directories instead of the parent directory. Of course, this will increase the network and IO load on your computer by three times. You do not want to try this hack/trick if you have a lot of sub-directories because of possible hardware limitations.
Sometimes syncing does not work (most likely because you have not synced recently enough or are syncing to an older CL than what you are currently synced to), then you need to force sync. Force sync will download the all files to your workspace even if Perforce believes it already has that version of the file in your workspace. This is great if you may have deleted or accidentally corrupted files in your workspace. Here are some examples of force syncing:
p4 sync -f filename<@CL>|
p4 sync -f directory\...<@CL>
The problem with force syncing is that it may not delete files in your workspace that should no longer be there, so I strongly recommend deleting everything that you are about to force sync before you start the force sync command.
by Phil for Humanity