Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

perforce

I'm trying to learn Perforce and want to delete a file from the depot(easy to do with p4 delete, p4 submit), but that deletes it from the client machine dir structure as well. I want to keep my local file in my directory intact.

The only way I can see to do this would be to move it out of the hierarchy that is under Perforce control before deleting. I was able to get my file back by syncing an earlier version.

Maybe I set up my client workspace wrong? Or am I misunderstanding a fundamental concept of source control? The client workspace is /home/user and I did it this way so I could add any file under my home directory without getting an error about the file not being under client's root.

FYI - Linux client and server running P4D/LINUX26X86/2009.1/222893 (2009/11/12)

Any advice appreciated. Thanks.

like image 942
Gary Avatar asked Jan 07 '10 22:01

Gary


People also ask

How do I delete Depot?

To delete a depot, use p4 depot -d depotname . To delete a depot, it must be empty; you must first obliterate all files in the depot with p4 obliterate . For local and spec depots, p4 obliterate deletes the versioned files as well as all their associated metadata.

How do you delete specific files?

Delete files using the right-click menu Another method involves selecting the file(s) that you want to delete in File Explorer and right-clicking (or pressing and holding) the selected item(s). In the contextual menu, choose Delete.

Which command is used for removing deleting files?

Use the rm command to remove files you no longer need. The rm command removes the entries for a specified file, group of files, or certain select files from a list within a directory.

How do I remove all files from a specific extension?

To remove files with a specific extension, we use the 'rm' (Remove) command, which is a basic command-line utility for removing system files, directories, symbolic links, device nodes, pipes, and sockets in Linux. Here, 'filename1', 'filename2', etc. are the names of the files including full path.


2 Answers

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
like image 174
Russell Davis Avatar answered Sep 21 '22 16:09

Russell Davis


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.

like image 35
Phil Wallach Avatar answered Sep 18 '22 16:09

Phil Wallach