Add files

To add files to the depot, create the files in your workspace, then issue the p4 add command. The p4 add command opens the files for add in the default pending changelist. The files are added when you successfully submit the default pending changelist.

To open multiple files for add, use a single p4 add command with wildcards.

To add files recursively, use the Helix Server ... wildcard.

A similar approach is to use the p4 reconcile -a * command. The p4 reconcile command opens files for add, delete, or edit to reconcile a workspace with changes made outside of Helix Server.

Example   Add files

Bruno has created two text files that he must add to the depot. To add all the text files at once, he uses the * wildcard when he issues the p4 add command.

C:\bruno_ws\Acme\dev\docs\manuals> p4 add *.txt
//Acme/dev/docs/manuals/installnotes.txt#1 - opened for add
//Acme/dev/docs/manuals/requirements.txt#1 - opened for add

Now the files he wants to add to the depot are open in his default changelist. The files are stored in the depot when the changelist is submitted.

Example   Add files with multiple *

Using the * wildcard in more than one place is possible.

C:\bruno_ws\Acme\dev\docs\manuals> p4 add *World*.*
//Acme/dev/docs/manuals/World.html#1 - opened for add
//Acme/dev/docs/manuals/WorldWorld.java#1 - opened for add
//Acme/dev/docs/manuals/TwoWorldsApart.json#1 - opened for add

Example   Add files with ...

Using ... allows you to add files in the specified directory and its subdirectories.

C:\bruno_ws\Acme\dev\docs\manuals> p4 add admin-guide/...
//Acme/dev/docs/manuals/admin-guide/readme.txt#1 - opened for add
//Acme/dev/docs/manuals/admin-guide/subdirectory1/procedure1.html#1 - opened for add

You can also issue the command without specifying any directory, in which case it applies to the current directory and its subdirectories:

C:\bruno_ws\Acme\dev\docs\manuals> p4 add ...
//Acme/dev/docs/manuals/admin-guide/readme.txt#1 - opened for add
//Acme/dev/docs/manuals/admin-guide/subdirectory1/procedure1.html#1 - opened for add
//Acme/dev/docs/manuals/developer-guide/readme.txt#1 - opened for add

Example   Submit a changelist to the depot

Bruno is ready to add his files to the depot. He types p4 submit and sees the following form in a standard text editor:

Change: new
Client: bruno_ws
User:   bruno
Status: new
Description:
        <enter description here>
Type:   public
Files:
    //Acme/dev/docs/manuals/installnotes.txt   # add
    //Acme/dev/docs/manuals/requirements.txt   # add

Bruno changes the contents of the Description: field to describe his file updates. When he’s done, he saves the form and exits the editor, and the new files are added to the depot.

You must enter a description in the Description: field. You can delete lines from the Files: field. Any files deleted from this list are moved to the next default changelist, and are listed the next time you submit the default changelist.

If you are adding a file to a directory that does not exist in the depot, the depot directory is created when you successfully submit the changelist.

For details on working with changelists, see Changelist-related tasks.