p4 clean

Synopsis

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 -n] [file ...]

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.
  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; ignore any settings specified by P4IGNORE for added files.

-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.

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