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

P4 CLI Documentation | 2025.2

# p4 annotate

Print file lines along with their revisions.

By default, ignores changes to text files over 10 MB in length.

Superusers of P4 Server can override this limit by setting the `dm.annotate.maxsize` configurable.

## Syntax

    p4 [g-opts] annotate [-a -c -i -I -q -t -T -u] [-doptions] FileSpec[revSpec]

Syntax and naming conventions

## Description

The `p4 annotate` command displays the revision number for each line of a revision (or range of revisions) of a file (or files). Using the `-u` option displays the name of the user who modified the change and the date when the modification occurred. To know why the modification happened, use the `p4 filelog` command on the indicated revision(s).

To display the changelist number associated with each line of the file, use the `-c` option.

If you specify a revision number, only revisions up to that revision number are displayed. If you specify a revision range, only revisions within that range are displayed.

By default, the first line of output for each file is a header line of the form:

    filename#rev - action change num (type)

where:

- filename#`rev` is the file’s name and revision specifier
- action is the operation the file was open for: `add`, `edit`, `delete`, `branch`, or integrate
- num is the number of the submitting changelist
- type of the file at the given revision

To suppress the header line, use the `-q` (quiet) option.

To print all lines (including lines from deleted files and/or lines no longer present at the head revision), use the `-a` (all) option.

The output of `p4 annotate` is highly amenable to scripting or other forms of automated processing.

Here is a sample of the `p4 annotate` output with the `-u` option. The first column specifies the revision number. The second column, the name of the user. The third column, the modify date. The fourth column, the revised line.

    320: mjones 2017/05/06         sr->w.digest.Clear();
    172: qsmith 2016/10/27         sr->w.size.Unknown();
    169: odavis 2018/04/21         sr->w.traitLot.Clear();
    196: ywillson 2017/06/12       sr->w.tampered.Clear();

Using tagged output with the `-u` option adds three lines: one for the user, one for the time, and one for the client workspace.

    ... upper 962279
    ... lower 961206
    ... user jbond
    ... time 2011/03/18 11:57:14
    ... client bond-james
    ... data   else

Note the upper and lower entries in the tagged output. For `-a` output, these indicate the revision range where the given line appears. For `-c` output, these indicate the changelist range where the given line appears.

## Options

Option | Description
--- | ---
`-a` | All lines, including deleted lines and lines no longer present at the head revision, are included. Each line includes a starting and ending revision.
`-c` | Display the changelist number, rather than the revision number, associated with each line. If you use the `-a` option and the `-c` option together, each line includes a starting and ending changelist number.
`-doptions` | Runs the diff routine with one of a subset of the standard UNIX diff options. See Usage notes for a listing of these options.
`-i` | Follow file history across branches. If a file was created by branching, the output includes revisions up to the branch point. The use of the `-i` option implies the `-c` option. The `-i` option cannot be combined with `-I`.
`-I` | Follow integrations into the file. If a line was introduced into the file by a merge, the source of the merge is indicated as the changelist that introduced the line. If that source was itself the result of an integration, that source will be used instead . The use of the `-I` option implies the `-c` option. The `-I` option cannot be combined with `-i`.
`-q` | Quiet mode, which suppresses the one-line header for each file.
`-t` | Force `p4 annotate` to display non-text (binary) files.
`-u` | Display the name of the user who modified the change and the date when the modification occurred.
`-T` | `--tab=N` | Align output to a tab stop of 8. You can specify a different tab value using the `--tab` option and specifying the desired value for N.
`g-opts` | See Global options.

## Usage notes

Can File Arguments Use Revision Specifier? | Can File Arguments Use Revision Range? | Minimal Access Level Required
--- | --- | ---
Yes | Yes | `read`

The diff options supported by `p4 annotate` are described in the following table:

Option | Name
--- | ---
`-db` | ignore changes made within whitespace
`-dl` | ignore line endings
`-dw` | ignore whitespace altogether

## Examples

`p4 annotate file.c` | Print all lines of `file.c`, each line preceded by the revision that introduced that line into the file.
`p4 annotate -c file.c` | Print all lines of `file.c`, each line preceded by the changelist number that introduced that line into the file.
`p4 annotate -a file.c` | Print all lines of `file.c`, including deleted lines, each line preceded by a revision range. The starting and ending revision for each line are included.
`p4 annotate -a -c file.c` | Print all lines of `file.c`, including deleted lines, each line preceded by a range of changelists. The starting and ending changelists for which each line exists in the file are included.

Your search for returned results