Search code examples
perforceperforce-client-spec

How can I recover my local files after a checkout overwrite in Perforce?


My local workspace has been modified. Before "Submit" I click "CheckOut",lead to my local files be coverer by server. How to recover my local files?

I am searching for a long time on net. But no use. Please help or try to give some ideas how to achieve this.

I use perforce in windows system. I use VS2010 IDE and QtCreate.

I try to recover from VS2010 IDE,but not find. I try to find local history in perforce,but not find.


Solution

  • Doing "check out" in P4V (p4 edit) does not in itself overwrite your local files. If you modified your local files and checked them out, your local changes are still in your workspace, and you should see the changes if you "Diff" the checked out file in your pending changelist.

    Doing a "get latest" (p4 sync) does not by default overwrite local files; the default behavior is to skip updating the file (and issue a warning) if the local file has been modified. This behavior is overridden by either:

    • the -f ("force") flag on the sync command
    • the noclobber option in the client workspace

    Once files have been opened with p4 edit (or otherwise), p4 sync will never overwrite them (even if you use the "force" flag). The only commands that will overwrite an open file are:

    • p4 revert (whose only purpose is to discard your local changes, so only run this if you're very certain you want to throw your unsubmitted work away)
    • p4 resolve (and only if you explicitly accept "theirs", i.e. the depot file, in its entirety, rather than merging it with your changes)

    Local changes that have not been submitted or shelved are not backed up anywhere in Perforce, which is why Perforce tries to protect those files from being accidentally overwritten. If you did a force-sync and clobbered your local changes, there is not any way to get them back, at least as far as Perforce is concerned; your best option would be automatic backups in your IDE. Failing that, you will need to redo your changes.