'Is it possible to recover deleted shelved files in perforce?

I had some changes shelved in a change list. Looks like I've deleted those shelved files by mistake. I don't keep much hopes of recovering them but given that shelving puts the changes in the server, Is there any chance that these are still accessible somewhere?

Thank you



Solution 1:[1]

If you've only deleted the local files, and not the shelved change itself, you should be able to recover them by unshelving the change:

p4 unshelve -s <change>

Solution 2:[2]

What worked for me is that i've had them diffed recently. So, i found them in the Perforce temp folder: C:\Users\\AppData\Local\Temp\p4v\PC101907_perforce_1666

Solution 3:[3]

If you have simply deleted one or more of the local but the shelve still exists, you can view the state of the file as of the last shelve with

p4 print -q //depot/path/to/file@=123456 

where //depot/path/to/file is the depot location and 123456 is the shelved changelist.

Note that other information I have found online suggests you can simply unshelve the specified file. This may work if the lost file was opened for 'edit', but if it is open for 'add' (as I just dealt with) then unshelving will merely die with the error "can't unshelve (already opened for add)".

Solution 4:[4]

I knew this was a thing, but I forgot and my coworker saved my bacon with a 15 file shelve that I accidentally deleted:

In my case, VS2019 was still opened and had all of my files in it. Going to each file and Undo-ing a few times restored the shelved version of the files. Was able to save them, and then just had to diff each file with current version to make sure only my intended changes were there.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 DRH
Solution 2 The Dark Brainer
Solution 3 saforrest
Solution 4 Phillip