How do I delete a file from depot, but leave local copy in tact?

I don't believe there is any way to keep a file you are deleting under Perforce. There is good reason for this, as if the file is deleted in the depot there is no reason (from a source code control perspective) to keep a copy in the client workspace.

I suspect the issue is the way you are using Perforce.

From what you have written it seems that you are using Perforce to backup/track files in your home directory structure. So the way you are using Perforce the "master" is in your home directory and the "copies" are in the depot.

This is not the intended use of a source control system as I understand it.

The master copy of all files are actually what is in the depot. From the depot, multiple clients (views) are made for purposes such as making changes, testing, and so on. The clients are transitory and can be created and deleted as required.

To do what you want to do you may need to rethink how you are using Perforce.


There is a way to do this, by going behind Perforce's back. Do the following:

  1. Rename the file you want to delete to something new
  2. Run p4 delete on the original filename
  3. p4 submit the change
  4. Rename the file back to the original name

Tags:

Perforce