View file history and diffs

Viewing file history and diffs helps you understand how a file has changed over time. You can review previous revisions, compare changes between revisions, and navigate through file history directly from Visual Studio Code.

View file history

You can view the full revision history of a file from either the editor or the Source Control view.

File history quick-pick

From the editor

  1. Open the file for which you want to view the history in the editor.

  2. Select View from the Menu bar.

  3. Open the Command Palette.

  4. Type P4: History, and press Enter.

From the Source Control view

  1. In the Source Control view, right‑click the file.

  2. Select Show history.

A quick pick list opens, showing all revisions of the file with the changelist number, description, date, and author.

Open a diff from the Source Control view

  1. In the Source Control view, right‑click the file.

  2. Select Open Diff.

The diff editor opens for the selected file.

Diff against a specific revision

You can compare a file against a specific revision or changelist.

  1. Select View from the Menu bar.

  2. Enter the revision number or changelist number when prompted.

  3. Open the Command Palette.

  4. Type P4: Diff revision, and press Enter.

  5. Enter the revision number or changelist number when prompted.

The diff editor opens, showing differences between the selected revisions.

When a diff is open, you can move between adjacent revisions by using the editor toolbar.

You can control when the navigation buttons appear by using the following setting under Extensions > P4 VS Code:

  • Editor Buttons: Diff Prev And Next

    • All diffable files (default): Show buttons for all P4‑tracked files.

    • Only on diffs: Show buttons only when a diff is open.

    • Never: Hide the buttons.

Open a specific revision

From the file history quick pick, select any revision to open that version of the file in a read‑only editor tab. You can then diff that revision against any other revision.