Helix Core is now P4. Product user interfaces will be updated soon. Learn more >>

P4 CLI Documentation | 2025.2

# Diff files

P4 Server allows you to diff (compare) revisions of text files. By diffing files, you can display:

- Changes that you made after opening the file for edit
- Differences between any two revisions
- Differences between file revisions in different branches

To diff a file that is synced to your workspace with a depot revision, issue the `p4 diff filename#rev` command. If you omit the revision specifier, the file in your workspace is compared with the revision you last synced, to display changes you made after syncing it.

To diff two revisions that reside in the depot but not in your workspace, use the `p4 diff2` command. To diff a set of files, specify wildcards in the filename argument when you issue the `p4 diff2` command.

The `p4 diff` command performs the comparison on your computer, but the `p4 diff2` command instructs the P4 Server to perform the diff and to send the results to you.

The following table lists some common uses for diff commands:

To diff | Against | Use this command
--- | --- | ---
The workspace file | The head revision | `p4 diff file` or `p4 diff file#head`
The workspace file | Revision 3 | `p4 diff file#3`
The head revision | Revision 134 | `p4 diff2 file file#134`
File revision at changelist 32 | File revision at changelist 177 | `p4 diff2 file@32 file@177`
The workspace file | A file shelved in pending changelist 123 | `p4 diff file@=123`
All files in release 1 | All files in release 2 | `p4 diff2 //Acme/rel1/... //Acme/rel2/...`

By default, the `p4 diff` command launches P4 Server’s internal diff application. To use a different diff program, set the `P4DIFF` environment variable to specify the path and executable of the desired application. To specify arguments for the external diff application, use the `-d` option. For details, refer to the P4 CLI Reference.

Your search for returned results