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.
On this page:
View file history
You can view the full revision history of a file from either the editor or the Source Control view.
From the editor
-
Open the file for which you want to view the history in the editor.
-
Select View from the Menu bar.
-
Open the Command Palette.
-
Type P4: History, and press Enter.
From the Source Control view
-
In the Source Control view, right‑click the file.
-
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
-
In the Source Control view, right‑click the file.
-
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.
-
Select View from the Menu bar.
-
Enter the revision number or changelist number when prompted.
-
Open the Command Palette.
-
Type P4: Diff revision, and press Enter.
-
Enter the revision number or changelist number when prompted.
The diff editor opens, showing differences between the selected revisions.
Navigate through 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.