Search code examples
cmdsynchronizationeditperforceworkspace

How do I change the client root from the command line for Perforce (p4)?


When I run the command below from the command line I get a 'C:\Program Files\CPU Analysis\data\data_summary.csv' is not under client's root 'c:\Users\'. error. How do I change the client's root so I can sync & edit my file? I would prefer to use a flag on the command line such as "p4 edit [flag] filepath" so the workspace is not permanently change on the system.

Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Users\212340141>p4 sync -f "C:\Program Files\CPU Analysis\data\data_summary.csv"
Path 'C:\Program Files\CPU Analysis\data\data_summary.csv' is not under client's
root 'C:\Users\'.

Solution

  • It's not clear why you don't want to permanently change the client root on your system.

    If you just want to work on this one file (data_summary.csv), and you want to work on it in a different location on your workstation than your normal Perforce workspace, the simplest approach is to just create a separate workspace, as in:

    cd c:\Program Files\CPU Analysis\data
    p4 -c my-summary-client client -o | p4 -c my-summary-client client -i
    p4 -c my-summary-client sync data_summary.csv
    p4 -c my-summary-client edit data_summary.csv
    

    It's also not clear whether you want to check your changes to data_summary.csv back into the repository or not. If you do not want to check your changes back in, there is a much simpler approach:

    p4 print -q -o "C:\Program Files\CPU Analysis\data\data_summary.csv" //depot/CPU_Analysis/data/data_summary.csv
    

    Then you'll have the latest version of data_summary.csv on your workstation, and you can open it in Excel.

    But since 'print' doesn't keep track of the fact that you have data_summary.csv and are working with it, you can't check any changes back in to the repository without properly sync'ing and edit'ing the file, which is why it's important to be clear about what you mean by 'edit my file'.