p4 clean

Restore workspace files to match the state of corresponding depot files.

The p4 clean command is equivalent to the p4 reconcile -w command.

Syntax

p4 [g-opts] clean [-e -a -d -I -l -K -m  -n] [file ...]

Syntax conventions

Description

The p4 clean command takes the following actions when finding inconsistencies between files in a user’s workspace and corresponding depot files:

  1. Files present in the workspace, but missing from the depot are deleted from the workspace.
    Warning

    Before you issue the command to have p4 clean delete files, make sure that you have successfully navigated to the correct directory. Otherwise, you might unintentionally delete local files that you want to keep.

  2. Files present in the depot, but missing from your workspace. The version of the files that have been synced from the depot are added to your workspace.
  3. Files modified in your workspace that have not been checked in are restored to the last version synced from the depot.

To limit the scope of p4 clean to add, edit, or delete, use the -a, -e, or -d options. For example, using the -a option deletes any new files in your workspace.

By default, p4 clean does not check files and/or paths mentioned in the P4IGNORE file if they have been added (rather than edited). Use the -I option to override this behavior and ignore the P4IGNORE file.

To preview the set of proposed workspace reconciliation actions, use the -n option.

Options

-a

Added files: Find files in the workspace that have no corresponding files in the depot and delete them.

-d

Deleted files: Find those files in the depot that do not exist in your workspace and add them to the workspace.

-e

Edited files: Find files in the workspace that have been modified and restore them to the last file version that has synced from the depot.

-I

Do not perform any ignore checking, which means to ignore any settings specified by P4IGNORE for added files.

-m Compare the file sync or submit time (in the depot) with the file modification time (in the workspace) to help determine whether the file has changed. Normally Helix Server uses file digests to determine whether files in the workspace differ from the head revisions of these files in the depot. This can be time consuming for large files. But when the timestamps are the same, the costly digest comparisons can be skipped. This option is only relevant if you are using clean to find changed files rather than files that were deleted or added.

-l

Display output in local file syntax with relative paths, similar to the workspace-centric view of p4 status.

-n

Preview the results of the operation without performing any action.

file

The files whose versions you want reconciled with their latest depot versions. If you omit this parameter, the files in your local working directory are used.

-K Suppress keyword expansion when updating +k type files on the client. See File type modifiers.

g-opts

See Global options.

Usage Notes

Can File Arguments Use Revision Specifier? Can File Arguments Use Revision Range? Minimal Access Level Required

No

No

read

  • The p4 clean command produces output in depot syntax. To see file names and paths in local syntax, you must use the -l option, or use p4 status. Compare the output of the following commands, one without the -l option, and the other one with the option.

    C:\test\local\client\copy\l>p4 clean -n bar
    //depot/copy/l/bar#none - deleted as c:\test\local\client\copy\l\bar
    C:\test\local\client\copy\l>p4 clean -n -l bar
    //depot/copy/l/bar#none - deleted as bar
  • When called without arguments, p4 clean adjusts the specified files in your workspace to reflect their latest state in the depot.

Related Commands

An equivalent for p4 reconcile -w

p4 reconcile