Perforce Public Knowledge Base - Renaming Files
Reset Search
 

 

Article

Renaming Files

« Go Back

Information

 
Problem

How do I rename a file?

Solution

For 2009.1+ servers

Make use of the p4 move command to move a file.

p4 move takes an already opened file and moves it from one client location to another, reopening it as a pending depot move. When the file is submitted with p4 submit, its depot file is moved accordingly.

For example, to rename "foo" to "bar" in the "ola" directory:

cd ola
p4 edit foo
p4 move foo bar
p4 submit
These commands mark the head revision of "foo" as "bar", and a "move/add" record is created. When anyone subsequently syncs to the "ola" directory, their workspace versions of "foo" is deleted and replaced with "bar".
 

To see the complete change history of "bar", including changes that affected it when it was named "foo", use the -i flag:

p4 changes -i bar

If you forget what "bar" was originally called, you can always find out by looking at the lines output by:

p4 filelog bar

For servers prior to 2009.1:
 

Rename a file by integrating the current file into a new file, and deleting the current one. For example, to rename "foo" to "bar" in the "ola" directory:

cd ola
p4 integ foo bar
p4 delete foo
p4 submit

This command process marks the head revision of "foo" as deleted. When anyone subsequently syncs to the "ola" directory, their workspace versions of "foo" is deleted and replaced with "bar". (Make sure you submit the "integ" and the "delete" in the same changelist).

To see the complete change history of "bar", including changes that affected it when it was named "foo", use the -i flag:

p4 changes -i bar

If you forget what "bar" was originally called, you can always find out by looking at the lines output by:

p4 filelog bar

Note:  Before renaming files, none of the files to be renamed should be opened for add/edit/delete/branch/integrate. The "integrate" command will only propagate changes from a submitted revision. Local, not-yet-submitted edits in your workspace will not be propagated to the integrated file.
Related Links

Feedback

 

Was this article helpful?


   

Feedback

Please tell us how we can make this article more useful.

Characters Remaining: 255