p4 add

Open files in a client workspace for addition to the depot.


p4 [g-opts] add [-c changelist] [-d -f -I -n] [-t filetype] file ...


p4 add opens files within the client workspace for addition to the depot. The specified files are linked to a changelist. The files are not actually added to the depot until the changelist is committed 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.

The commands p4 add * or p4 add ... are synonymous to p4 reconcile -a *

This means that any files in the workspace that do not exist in the depot are opened for add. Using the -a option does not affect the behavior of p4 add -d

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 exist in your workspace when you run p4 submit. Otherwise the submission fails. 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 option.

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 option to ignore the contents of any P4IGNORE files.

When adding files, the command first examines the typemap table (p4 typemap) to see if the system administrator has defined a file type for the files 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, the command 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 option explicitly specifies a file type, overriding both the typemap table and the default file type detection mechanism.

To add files containing the characters @, #, *, and %, use the -f option. This option forces literal interpretation of characters otherwise used by the Helix server as wildcards.

If you open a file for edit or move/add, and another user 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 option ("downgrade"). More specifically:


-c changelist

Opens the files for add within the specified changelist. If this option is not used, the files are linked to the default changelist.


Downgrade file open status to simple add.


Use the -f option to force inclusion of wildcards in filenames. See File Specifications for details.


Do not perform any ignore checking; ignore any settings specified by P4IGNORE.


Preview which files would be opened for add, without actually changing any files or metadata.

-t filetype

Adds the file as the specified filetype, overriding any settings in the typemap table.

See File Types for a list of Helix server file types.


See Global Options.

Usage Notes

Can File Arguments Use Revision Specifier? Can File Arguments Use Revision Range? Minimal Access Level Required





p4 add -t binary file.pdf

Assigns a specific file type to a new file, overriding any settings in the typemap table.

p4 add -c 13 *

Opens all the files within the user’s current directory for add, and links these files to changelist 13.

p4 add README ~/src/*.c

Opens all *.c files in the user’s ~/src directory for add; also opens the README file in the user’s current working directory for add. These files are linked to the default changelist.

p4 add -f *.c

Opens a file named *.c for add.

To refer to this file in views, or with other commands, you must subsequently use the hex expansion %2A in place of the asterisk.

For more information, see Limitations on characters in filenames and entities.

Related Commands

To open a file for edit

p4 edit

To open a file for deletion

p4 delete

To move (rename) a file

p4 move

To copy all open files to the depot

p4 submit

To read files from the depot into the client workspace

p4 sync

To create or edit a new changelist

p4 change

To change default behavior of text and binary file detection

p4 configure

To list all opened files

p4 opened

To revert a file to its unopened state

p4 revert

To move an open file to a different pending changelist

p4 reopen

To change an open file’s file type

p4 reopen-t filetype