Update a client workspace's have list without actually copying any files
Using p4 flush incorrectly can be dangerous. If you use p4 flush incorrectly, the server's metadata will not reflect the actual state of your client workspace, and subsequent Perforce commands will not operate on the files you expect! Do not use p4 flush until you fully understand its purpose.
It is rarely necessary to use p4 flush.
p4 flush performs half the work of a p4 sync. Running p4 sync filespec has two effects:
p4 flush performs only the second of these steps. Under most circumstances, this is not desirable, since a client workspace's have list should always reflect the client workspace's true contents. However, if the client workspace's contents are already out of sync with the have list, p4 flush can sometimes be used to bring the have list in sync with the actual contents. Since p4 flush performs no actual file transfers, this command is much faster then the corresponding p4 sync.
Use p4 flush only when you need to update the have list to match the actual state of the client workspace. The Examples subsection describes two such situations.
-n | Display the results of the flush without actually performing the flush. This lets you make sure that the flush does what you think it does before you do it. |
g_opts | See global options section. |
Can File Arg Use Revision Specifier? |
Can File Arg Use Revision Range? |
Minimal Access Level Required |
---|---|---|
Yes | Yes | read |
Since p4 flush updates the have list without copying files, and p4 sync -f updates the client workspace to match the have list, p4 flush files followed by p4 sync -f files is almost equivalent to p4 sync files. This means that a bad flush can be almost entirely fixed by following it with a p4 sync -f of the same file revisions that were originally flushed.
Unfortunately, this is not a complete remedy, since any file revisions that were deleted from the have list by p4 flush will remain in the client workspace even after the p4 sync -f. In this case, you will need to manually remove deleted file revisions from the client workspace.
/usr/joe/project1/subproj
//depot/joe/proj1/subproj/... //joe/...
/usr/joe/project1
//depot/joe/proj1/... //joe/...
To copy files from the depot to the client workspace | p4 sync |
To bring the client workspace in sync with the have list after a bad p4 flush | p4 sync -f |