Step 10: Configure ignored files | Admin

It is best practice to ignore (not version) some files for security or performance reasons.

  • Versioning files makes them available to other users on the project. If you version user-specific settings or secret keys, it causes setting conflicts and security issues.

  • Versioning files that are automatically created and updated by a program is not efficient. These files can be regenerated by the program that generates them.

Specify files to ignore

There are two ways to specify ignored paths in P4. You can use one, the other, or both.

Stream level for all users

In P4, you can specify ignored paths at the stream level in the Ignored field or by editing an existing stream. This applies the exclusions to all users. Any child streams automatically inherit the same excluded paths.

It is best to reserve ignoring paths at the stream level for a few critical paths and use a p4ignore for more specific paths. Having many lines in the Ignored field can cause issues when merging between streams.

To learn more, see Set ignored paths at the stream level for all users.

p4ignore file for individual users

P4 also supports ignoring files using a p4ignore file, which is a file stored on each user's computer. A p4ignore file is more powerful than specifying paths to exclude at the stream level. Make sure the file is always included in each user workspace. Some users prefer the flexibility this provides because each user can edit the p4ignore file or add extra files. However, this requires your entire team to be well-trained in p4ignore files.

Set ignored paths at the stream level for all users

  1. To edit an existing stream, in P4V, right-click it in the Stream Graph and choose Edit Stream.

    If the Stream Graph is not visible, click the + button and select Stream Graph.
  2. Add one line for each file path to ignore. If you are using P4 with Unreal Engine, you can use the following as a basic set of ignored paths to include at the stream level.

    • /Saved/...

    • /Intermediate/...

    • /DerivedDataCache/...

    • /FileOpenOrder/...

    • /obj/...

    • .pdb

    • -Debug.*

    • /.vs/...

    • .sln

  3. To ignore: Add this line in the Ignored field:
    All files that end in .env .env
    All files in a folder named DerivedDataCache, including subfolders /DerivedDataCache/…
    All files in a folder named Intermediate that is in a folder named Build /Build/Intermediate/…

    Remember that:

    • P4 is case-sensitive, so double check your paths to make sure you are using casing consistently.

    • * can be used as a wildcard to match any number of characters.

    • A slash (/) at the end of a path will only match directories. In any other place in the path, it matches files or directories.

    • You can use wildcards at the end of a line:

      • Use ... to match any number of characters in any subfolders.

      • Use * as a recursive wildcard to match any number of characters, but no subfolders. Recursive wildcards can affect performance.

  4. Click Apply to save the changes and keep the window open, or click OK to save the changes and close the window.

Create the ignore file

Use the following steps to set up and create the ignore file.

  1. Create an ignore file.

  2. Test the ignore file.

  3. Add the ignore file to P4 Server.

To learn more about creating an ignore file, you can also watch this video.

Step 1: Create an ignore file

  1. To create an ignore file, open a text editor and save an empty file named p4ignore.txt (typically for Windows) or .p4ignore (typically for Linux or macOS) in your workspace root. For example: C:\Users\YourName\Perforce\Yourname_Workspace\.p4ignore.

    An ignore file in a folder affects all files in the folder. Normally, you create an ignore file in your workspace root. You can also have ignore files in subfolders that affect only those folders and their children.
  2. In the file, enter one line for each file path to ignore. If you are using P4 with a game engine, use the examples in p4ignore file examples to get started.

    Remember that:

    • P4 is case-sensitive, so double check your paths to make sure you are using casing consistently.

    • * can be used as a wildcard to match any number of characters.

    • A slash (/) at the end of a path will only match directories. In any other place in the path, it matches files or directories.

    • A ! at the beginning of a line ensures that matched files are not ignored, even if a previous rule matches them.

    • You can use wildcards at the end of a line:

      • Use ... to match any number of characters in any subfolders.

      • Use * as a recursive wildcard to match any number of characters, but no subfolders. Recursive wildcards can affect performance.

  3. Save the ignore file.

To learn more about ignore files, see P4IGNORE in the P4 CLI Reference .

Step 2: Test the ignore file

You can add a file in P4V or use the p4 ignore command to test if individual lines in your ignore file are working as intended.

Add a file in P4V

In P4V, add a file that should be ignored.

  1. Add a file or folder affected by the rule to the workspace folder on your computer.

  2. Change logging preferences to get feedback on ignored files in the Log pane.

    In P4V, choose Edit > Preferences (Windows) or P4V >Preferences (Mac). In the Preferences dialog box, select Logging. Check the box Show p4 reporting commands. Click OK to save your changes and exit the dialog box.

  3. Choose View > Workspace Tree. The workspace tree shows files and folders in your workspace. Click Refresh on the toolbar to see the file you added in the workspace tree.

  4. In the workspace tree, select the file to be ignored.

  5. On the toolbar, click Add to add the selected file to a default changelist.

    To submit new or changed files to the P4 Server, you use a changelist. A changelist defines a logical grouping of work across a set of files and folders.

  6. To see your pending changelist, choose View > Pending Changelists. In the Pending tab in the right pane, you will see the default changelist. Expand the changelist to view the list of files.

  7. If you added the rule correctly, the affected file is not added to the changelist. In the Log pane, the messagefile(s) not in client view is displayed, and in a dialog box, a files were not marked for add message is displayed.

Use the p4 ignores command

In the terminal, run p4 ignores -i -v path , where path is the path to the file to check.

The output displays if the file was ignored or not, and which line in the ignore file is the one that matched.

Step 3: Add the ignore file to P4 Server

Complete the following steps to add your ignore file to the server.

  1. In P4V, click select the .p4ignore file in the workspace.

  2. On the toolbar, click the Add button, or right-click the file and select Mark for Add. This adds the file to the default changelist.

  3. To see your pending changelists, choose View > Pending Changelists. In the Pending tab in the right pane, you will see the default changelist. Expand the changelist to view the list of files.

  4. Select the pending changelist and click Submit on the toolbar.

  5. Enter a changelist description so you and your team can see what each person did, and which tasks are complete.

  6. Click Submit.

Your ignore file is now saved in the depot so that it will be available to your users. Optionally, you can create and add an ignore file for your colleagues to use as a template, so that they can create their own ignore files as needed.

Note the name and location of the ignore file so that users can add it.

p4ignore file examples

What's next

Next, populate the stream with files.

Go to Step 11: Add and work with versioned files.