p4 obliterate

Removes files and their history from the depot.


p4 [g-opts] obliterate [-y -A -b -a -h] file[revRange] ...


Use p4 obliterate with caution. This is one of only two commands in Perforce that actually removes file data. (The other command that removes file data is the archive-purging option for p4 archive.)

The p4 obliterate command actually deletes the server’s copy of a file’s data, precluding any possibility of recovery. (By contrast, the p4 delete command merely marks the latest revision as deleted, but leaves earlier revisions intact in the depot.)


p4 obliterate can be used by Perforce administrators to permanently remove files from the depot. The file is removed from the Perforce service, along with all associated metadata, including references to the file in labels, the have list, and so on. After p4 obliterate completes, it appears to the service as if the affected file(s) had never existed. Copies of files in user workspaces are left untouched, but are no longer recognized as being under Perforce control.

p4 obliterate requires at least one file pattern as an argument. To actually perform the obliteration, the -y option is required; without it, p4 obliterate merely reports what it would do without actually performing the obliteration.

If you specify a single revision (for instance, p4 obliterate file#3), only that revision of the file is obliterated. If you specify a revision range (for instance, p4 obliterate file#3,5), only the revisions in that range are obliterated.


p4 obliterate myfile does not obliterate a shelve of the file (archive or metadata). When you attempt to unshelve a file that has been obliterated, you will get an error. To recover the content of that file, print the file. To get rid of the shelve, delete the shelf.

p4 obliterate with a file spec does not obliterate a shelve of the file.


-y filespec

Perform the obliterate operation. Without this option, p4 obliterate merely reports what it would do.


Obliterate a revision marked for archive. By default, archived revisions are skipped.


Restrict files in the argument range to those that are branched, and to files that are both the first revision and the head revision. This option is useful for removing old branches (where only one revision exists) while preserving files that have been modified post-branch. You can greatly improve the performance of obliterate -b by using the -a option with -b.


Skip the (potentially resource-intensive) search of db.archmap and do not remove the file from the server; only its metadata. Although the file is not removed from disk, you can use -a in conjunction with -b to speed up obliteration of branched files known to exist only as lazy copies.


Skip the search of db.have when looking for matching records to delete. The next time a client workspace that refers to these files is synced, any such files in the workspace will also be removed from the workspace. (This is often the desired behavior, for example, in client workspaces on build machines.)


See Global Options.

Usage Notes

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





p4 obliterate dir/...

Do not obliterate any files; list the files that would be obliterated with the -y option.

In this case, all files in directory dir and below would be subject to deletion with the -y option.

p4 obliterate -y file

Obliterate file from the depot. All history and metadata for every revision of file are erased.

p4 obliterate -y file#3

Obliterate only the third revision of file.

If #3was the head revision, the new head revision is now #2 and the next revision will be revision #3.

If #3 was not the head revision, the head revision remains unchanged.

p4 obliterate -y file#3,5

Obliterate revisions 3, 4, and 5 of file.

If #5was the head revision, the new head revision is now #2, and the next revision will be #3.

If #5 was not the head revision, the head revision remains unchanged.

Related Commands

To mark a file deleted at its head revision but leave it in the depot. This is the normal way of deleting files.

p4 delete

Instead of obliterating files, you can save disk space on a local depot by archiving some of its revisions to an archive depot. History of changes to these files is preserved.

p4 archive

To restore archived revisions from an archive depot. (You cannot restore obliterated files, but you can restore archived files.)

p4 restore