11. Adding and Removing Files

Integrating a branch will bring existing files into your tree, but you may still want to add new files or remove existing ones. Adding files is easily done be creating the file and then running the p4 add command like so:

% p4 add filename

If you want to add a whole tree of files, run a command like:

% find . -type f | xargs p4 add

Note:

Perforce can track UNIX symlinks too, so you can probably use \! -type d as the matching expression in find(1) above. We don't commit symlinks into the source tree of FreeBSD though, so this should not be necessary.

Doing a p4 submit will then copy the file to the depot on the server. It is very important to only add files, not directories. Explicitly adding a directory will cause Perforce to treat it like a file, which is not what you want.

Removing a file is just as easy with the p4 delete command like so:

% p4 delete filename

This will mark the file for deletion from the depot the next time that a submit is run. It will also remove the local copy of the file, so beware.

Of course, deleting a file does not actually remove it from the repository.

Deleted files can be resurrected by syncing them to a prior version. The only way to permanently remove a file is to use the p4 obliterate command. This command is irreversible and expensive, so it is only available to those with admin access.

All FreeBSD documents are available for download at http://ftp.FreeBSD.org/pub/FreeBSD/doc/

Questions that are not answered by the documentation may be sent to <freebsd-questions@FreeBSD.org>.
Send questions about this document to <freebsd-doc@FreeBSD.org>.