13 Renaming files

Perforce does not have a built-in way of renaming files or moving them to a different part of the tree. Simply copying a file to the new location, doing a p4 add on it, and a p4 delete on the old copy, works, but does not preserve change history of the file. This can make future integrations with parents and children very bumpy, in fact. A better method of dealing with this is to do a one-time, in-tree integration, like so:

% p4 integrate -i oldfile newfile
% p4 resolve
% p4 delete oldfile
% p4 submit

The integration will force Perforce to keep a record of the relationship between the old and new names, which will assist it in future integrations. The -i flag tells it that it is a “baseless” integration, meaning that there is no branch history available for it to use in the integration. That is perfect for an integration like this, but should not be used for normal branch-based integrations.