Previous Table of Contents Index Next
Perforce 2009.1: Command Reference



p4 add
Synopsis
Open file(s) in a client workspace for addition to the depot.
Syntax
p4 [g-opts] add [-c changelist#] [-f -n] [-t type] file...
Description
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 workspace 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 linked to the default changelist. Use -c to specify a different changelist. (Or use the p4 change command to move files from the default changelist to a numbered changelist.)
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 8192 bytes of the file 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 10MB are assigned filetype text+C and stored in full. Binary revisions are stored as full files.
To explicitly specify a file type, overriding both the typemap table and Perforce's default file type detection mechanism, use the -t filetype flag.
To add files containing the characters @, #, *, and %, use the -f flag. This flag forces literal interpretation of characters otherwise used by Perforce as wildcards.
Options
-c changelist
Opens the files for add within the specified changelist. If this flag is not used, the files are linked to the default changelist.
Please see the File Types chapter for a list of Perforce file types.
Use the -f flag to force inclusion of wildcards in filenames. See the File Specifications chapter for details.
Usage Notes
Can File Arguments Use
Revision Specifier?
Wildcards in file specifications provided to p4 add are expanded by the local operating system, not by the Perforce server. For instance, the ... wildcard cannot be used with p4 add.
In Perforce, there is no difference between adding files to an empty depot and adding files to a depot that already contains other files. You can populate new, empty depots by adding files from a client workspace with p4 add.
Do not use ASCII expansions of special characters with p4 add -f. To add the file [email protected], use
p4 add -f [email protected]
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.
Examples
Opens all the files within the user's current directory for add, and links these files to changelist 13.
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.
To refer to this file in views, or with other Perforce commands, you must subsequently use the hex expansion %2A in place of the asterisk.
Related Commands
p4 reopen -t filetype
 


Previous Table of Contents Index Next

Perforce 2009.1: Command Reference
Copyright 1999-2009 Perforce Software.