0

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

1 Answers1

2

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.

Samwise
  • 68,105
  • 3
  • 30
  • 44
  • So if I do this p4 clean -d //depot/source/... it should not delete anything in the depot ? I don't want to delete anything in the depot. Thanks in advance. –  Dec 03 '19 at 00:31
  • 1
    No, `p4 clean` will only affect your workspace. It *will* irrevocably delete modifications in your workspace that have not yet been submitted to the depot. – Samwise Dec 03 '19 at 00:52
  • Just tried it. I now do a "p4 clean" to grab missing files and follow it up with a "p4 snyc" which grabs any recent submitted changes in the depot. A perfect solution to my problem. Thank you very much for your help. –  Dec 03 '19 at 20:20
  • If you can avoid manually deleting your workspace files (use `p4 sync FILE#none` instead of `rm FILE`) you won't need the `p4 clean` step. When you remove files by doing a `p4 sync` to the `#none` revision, a subsequent `p4 sync` to the `#head` revision will just automatically fetch the files you're missing. – Samwise Dec 04 '19 at 04:06
  • I suggest you define a .p4ignore file in your $HOME directory and set P4IGNORE variable to it. You can list the files you don't want 'p4 clean' to delete. As example, my ~/.p4ignore file contains .p4config and few other dot files in my client root. – Dom Jun 30 '20 at 13:53