Perforce Public Knowledge Base - Renaming Depot Directories
Perforce Software logo
Reset Search



Renaming Depot Directories

« Go Back



Moving or renaming a depot directory or branch.


Use the p4 integrate (and p4 delete) command to move entire directories (branches). Use the p4 move command to move/rename files within branches.

To move or rename a directory or branch, branch the existing directory into a new directory (using p4 integ) and then delete the existing directory (using p4 delete). For example, to rename
//depot/widgets to //depot/main/widgets issue the following commands:

p4 integ //depot/widgets/... //depot/main/widgets/...
p4 delete //depot/widgets/...
p4 submit

Make sure to submit the "integ" and the "delete" in the same changelist.

This series of commands marks the head revisions of files in //depot/widgets as deleted. To remove your //depot/widgets files and copy in the //depot/main/widgets files, you should do a p4 sync with your client view mapped to //depot/main/widgets

The complete history of the files in the new directory can be shown with p4 filelog -i and p4 changes -i.

Note:  Before renaming files, none of the files to be renamed should be opened for add/edit/delete/branch/integrate. The p4 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. Also, you are unable to delete any opened source files in the directory that you are trying to rename. Attempting to delete a file that is already opened for edit generates an error. For example:

$ p4 delete main.c
//depot/test/main.c - can't delete (already opened for edit)

Again, in order to have all source directory files renamed and all current edits propagated to the target, all opened files in that directory tree must either be submitted or reverted.

If you want to move your current workspace edits to a new target directory, please consult the KB article: Branching Work In Progress.

Note: The p4 move command should only be used for intra-branch file rename or move, that is, renaming a file within the same directory, or between folders within the same directory tree. The p4 move command should not be used to move entire branches, since that breaks atomicity of the move action for future integrations (half the move is in one branch and half is in another). The p4 move command is intended for moves/renames/refactoring that happen as part of development and not for restructuring the depot at the inter-branch level. The branch here refers to a (inter-) branch that will potentially integrate to another branch (p4 integrate).  The folders refers to the intra-branch that will only appear in one side of the branchspec in any future integration, so that both the move/add and move/delete actions remain in the same side of an integration.

After you have renamed the depot directory, you will likely want to change references to the old depot path name to reflect the new name so that all users can view and sync to files from the new depot path. To avoid errors, check the following for references to the newly renamed depot path:

  • Protection tables
  • Client workspace specifications
  • Labels
  • Branch specifications
  • Triggers
  • Scripts that refer to the depot directory
Related Links



Was this article helpful?



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

Characters Remaining: 255