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 p4 add 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 do not 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
p4 obliterate. This command is irreversible
and expensive, so it is only available to those with admin
access.