Helix Core is now P4. Product user interfaces will be updated soon. Learn more >>

P4 CLI Documentation | 2025.2

# p4 delete

Open files in a client workspace for deletion from the depot.

## Syntax

    p4 [g-opts] delete [-c PendingChangelist] [-n -k -v] [--remote=remote] FileSpec1 [FileSpec2 ...]

Syntax and naming conventions

## Description

The `p4 delete` command opens files in a client workspace for deletion from the depot. The files to delete are indicated by one or more filespecs.

The files to delete are immediately removed from the client workspace, but are not deleted from the depot until the corresponding changelist is committed with `p4 submit` . Each deleted file gets a new head revision that marks the file as deleted. If `p4 sync` is used to bring the head revision of this file into another workspace, the file is deleted from that workspace.

A file that is open for deletion does not appear on the have list The list of file revisions most recently synced from the depot into the workspace. In other words, the list of files that the client workspace has. of the workspace.

Although it appears as if a deleted file has been removed from the depot, revisions of the deleted file remain accessible. To permanently remove an archive file Versioned files that users submitted to a depot. and its metadata Information that P4 Server maintains, such as who created file revisions in the depot, whether the file is a 'lazy copy,, the current state of client workspaces, protections, groups, users, labels, streams, and branches. Metadata is stored in the server database and is separate from the 'archive files' that users submit from their client workspace into the depot. from the depot, a user with `admin` access level A permission assigned to a user to control which commands the user can run. See also the 'protections' entry in this glossary and the 'p4 protect' command in the P4 CLI Documentation. uses the p4 obliterate command.

## Options

Option | Description
--- | ---
`-c PendingChangelist` | Opens files for `delete` and associates the deletion action with the specified pending changelist. If no pending changelist is specified, the deletion action is associated with the default changelist.
`-k` | Delete the file on the shared versioning service, but keep a copy of the deleted file in your workspace.
`-n` | Preview which files would be opened for delete, without actually changing any files or metadata.
`--remote=`remote`` | Opens the file for delete in your personal server, and additionally — if the file is of type `+l` — takes a global exclusive lock on the file in the shared server from which which you cloned the file. For more information, see the section Support for exclusive locking in the Fetching and Pushing chapter of P4 Server Administration Documentation.
`-v` | Delete a file that is not synced into the client workspace. To use this option, specify these files in depot syntax; because such files are not synced, client syntax or local syntax can introduce ambiguities in the list of files to delete. (If the files are synced, `p4 delete -v file` removes the files from your workspace in addition to opening them for deletion.) To delete a set of files without transferring them to your workstation when another version of these files already exists in your workspace, use `p4 sync``-k file` , followed by `p4 delete -k file` . This allows you to delete a file that is in the depot without affecting the file (by the same name) in your workspace. For example, if you have `myfile` version 5 in the depot and `myfile` version 6 in your workspace, this sequence of commands, allows you to keep version 6 but delete version 5. If you don’t do this and just do `p4 delete -v` , it will delete version 5 in the depot and version 6 in the workspace.
`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 | `open`

- A file that has been deleted from the client workspace with `p4 delete` can be reinstated in the client workspace and removed from the pending changelist with `p4 revert` . To do this, you must revert the deletion before submitting the changelist.
- P4 Server does not prevent users from opening files that are already open; its default scheme is to allow multiple users to open a file simultaneously, and then resolve file conflicts with `p4 resolve` . To prevent someone else from opening a file once you’ve opened it, use `p4 lock` . To determine whether or not another user already has a particular file open, use `p4 opened``-a file` .
- Using an `+Sn` file modifier results in special behavior when you delete and read a file: no file reversions are deleted that were submitted before the add or delete. For example, if a file of type `+S2` is marked as deleted in revision 5, and then re-added with the same file type and modifier, revisions 3 and 4 are not purged.

## Examples

`p4 delete //depot/README` | Opens the file called `README` in the depot’s top level directory for deletion. The corresponding file within the workspace is immediately deleted, but the file is not deleted from the depot until the default changelist is submitted.
`p4 delete -c 40 *.bat *.txt` | Opens for deletion the files in the current client workspace that have the `.bat` and `.txt` extensions. Such files are immediately removed from the client workspace, but won’t be deleted from the depot until changelist `40` is committed with `p4 submit` .

## Related commands

To open a file for add | `p4 add`
To open a file for edit | `p4 edit`
To copy all open files to the depot | `p4 submit`
To read files from the depot into the client workspace | `p4 sync`
To create or edit a new changelist | `p4 change`
To list all opened files | `p4 opened`
To revert a file to its unopened state | `p4 revert`
To move an open file to a different changelist | `p4 reopen`

Your search for returned results