John Cowan
John Cowan

Reputation: 1674

Perforce Commandline Get Contents of Deleted File

I've done this several times in git, but not sure how to do it in p4 commandline. Google is not helping me - or maybe I'm not searching correctly.

I have a file that was deleted: /path/to/file/index.html Now, I need to get the contents of that file as it was before being deleted. I do not want to bring it back to life, I just need the contents.

The changelist for the delete is 125325.

What would be the easiest way to do this?

Upvotes: 2

Views: 130

Answers (1)

Samwise
Samwise

Reputation: 71454

To sync it to your workspace (this is kind of similar to the git checkout method that you're probably familiar with):

p4 sync /path/to/file/index.html@125324

If you just want to see the content (e.g. dump it to stdout), you can use p4 print (if you were to use the depot path of the file rather than a local path, p4 print doesn't require that the file is mapped to your workspace):

p4 print /path/to/file/index.html@125324

Note that the rev specifier I'm using is the changelist before the file was deleted. You can also use the prior revision number, or an earlier rev/changelist, a particular date, etc. See p4 help revisions for all the ways you can reference older versions of files.

Upvotes: 4

Related Questions