p4 add opens files within the client workspace for addition to the depot. The specified file(s) are linked to a changelist; the files are not actually added to the depot until the changelist is sent to the server with
p4 submit. The added files must either not already exist in the depot, or exist in the depot but be marked as deleted at the head revision.
To open a file with p4 add, the file must exist in your client view, but does not need to exist in your workspace at the time of
p4 add. The file must, however, exist in your workspace when you run
p4 submit, or the submission will fail.
p4 add does not create or overwrite files in your workspace; if a file does not exist, you must create it yourself.
By default, the specified files are opened in the default changelist. To open the files in a specified changelist, use the
-c flag. (To move files from the default changelist to a numbered changelist, use the
p4 change command.)
By default, p4 add skips over files mentioned in any applicable
P4IGNORE files. To override this behavior, use the
-I flag to ignore the contents of any
P4IGNORE files.
When adding files, Perforce first examines the typemap table (p4 typemap) to see if the system administrator has defined a file type for the file(s) being added. If a match is found, the file's type is set as defined in the typemap table. If a match is
not found, Perforce examines the first bytes of the file based on the
filesys.binaryscan configurable (by default, 65536 bytes) to determine whether it is
text or
binary, and the files are stored in the depot accordingly. By default, text file revisions are stored in reverse delta format; newly-added text files larger than the limit imposed by the
filetype.maxtextsize configurable (by default, 10 MB) are assigned filetype
text+C and stored in full. Files compressed in the
.zip format (including
.jar files) are also automatically detected and assigned the type
ubinary. Other binary revisions are stored in full, with compression.
The -t filetype flag explicitly specifies a file type, overriding both the typemap table and Perforce's default file type detection mechanism.
To add files containing the characters @,
#,
*, and
%, use the
-f flag. This flag forces literal interpretation of characters otherwise used by Perforce as wildcards.
If you open a file for edit or move/add, and another subsequently deletes the file you opened, the operation will fail with an error when you submit the changelist. To ensure that you create the desired target file, specify the
-d flag ("downgrade"). More specifically:
If you manually expand the @ sign and attempt to add the file
status%40june.txt, Perforce interprets the
% sign literally, expands it to the hex code
%25, resulting in the filename
status%2540june.txt.