Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Recover deleted files from Perforce

Tags:

perforce

I deleted a file from Perforce in the last month. Is there a way to retrieve it from P4?

If so, what command can I use?

Note: I'm not the admin for p4. And I don't want the file back in P4 but I just want it in my local workspace.

Also, I don't know the exact timeframe when I deleted it in last month...What command can I run?

I'm running P4 on windows. I'll appreciate if someone can provide equivalent command for windows

Thanks!

like image 293
Mike Avatar asked Jan 11 '12 19:01

Mike


People also ask

How do you undo p4 delete?

Instead, users must revert the files to remove the mark for deletion. To do this, simply right-click on the folder or files in P4V and select Revert.

Does p4 sync delete files?

If p4 sync is used to bring the head revision of this file into another workspace, the file is deleted from that workspace.

What does clean do in perforce?

The p4 clean command takes the following actions when finding inconsistencies between files in a user's workspace and corresponding depot files: Files present in the workspace, but missing from the depot are deleted from the workspace. Files present in the depot, but missing from your workspace.

How do I get my files back after RM?

To recover deleted files you will be provided with a single file recovery option and all files recovery option. If you want to recover a single file, you can go with “-restore-file”. On the other hand, if you want to restore all deleted files, you can go with “-restore-all”.


2 Answers

When you delete a file in Perforce, it creates a "deleted" revision, but the archive file is still there.

In the Perforce P4V GUI in the depot veiw, there is a filter symbol on top of the explore pane Yellow Flag.

Click on this and select "Show Deleted Depot Files".

Find the file you want to restore and right-click on it. Select "Rollback..." and revert it to the previous revision of that file (before it was deleted.)

By default it will create a new changelist, be sure to select the one you want if you already have one.

On the command line: p4 sync //depot/folder/subfolder/filename@changelist

like image 79
bluecap Avatar answered Sep 16 '22 12:09

bluecap


If you haven't committed the change list of deleted files to the repository, right click on the folder containing the deleted files in p4v and choose Get Revision. Be sure to check Force Operation and then Click Get Revision. Then the deleted files will be restored from p4 server.

ref: https://forums.perforce.com/index.php?/topic/1479-how-to-restore-files-deleted-in-p4c-workspace/#entry4726

like image 38
zwcloud Avatar answered Sep 17 '22 12:09

zwcloud