Search code examples
perforcep4vperforce-client-specperforce-stream

Sync ONLY the differences in the depot but recieving error "- must refer to client"


I want to be able to sync ONLY the differences in the depot into my workspace. I do not want to re-sync all the source files which already match.

I currently can see the difference with this command:

p4 diff -sd //depot/source/...

But when trying to use this command to sync the depot differences to my local workspace:

p4 diff -sd //depot/source/... | p4 -x - sync -f | p4 //depot/source/...

I receive this message in the terminal:

"- must refer to client"

Note: Prior to performing all of the above command I set my client using

p4 set P4CLIENT=MYWORKSPACE

Solution

  • To sync only the files that have been updated on the server since you last synced, do:

    p4 sync
    

    The default behavior of the p4 sync command is to sync only changed files; you don't need to perform any special gyrations to make that happen.

    The server's notion of what's different between the server and your workspace is dependent on its records of what it sent you the last time you synced. If you've messed around with your workspace in unsupported ways (i.e. you've modified files that Perforce made read-only without "opening" them for modification), those records have been invalidated. You can fix this one of two ways, depending on what you want to do with your modifications:

    p4 reconcile
    

    will open the files you modified, allowing you to choose between reverting the modifications or submitting them.

    p4 clean
    

    will simply overwrite your modifications, similar to a p4 sync -f, but p4 clean will do a diff to figure out which files you modified and will only re-sync those files.