Last updated: Apr 6, 2024
Reading time·4 min
To view the Git history in VS Code:
Selecting a specific commit opens a diff view of the changes introduced by the given commit.
Here is a short click that demonstrates how to use the TIMELINE view.
You can right-click on an entry to:
The Timeline view automatically shows the timeline for the currently selected file.
The built-in Git extension contributes a timeline that shows the Git commit history of the given file.
By default, the view is collapsed in Explorer (the left sidebar), so you have to click on it to expand it.
Alternatively, you can:
Open a file.
Press:
Ctrl
+ Shift
+ P
on Windows and Linux.Command
+ Shift
+ P
on macOS.F1
to open the Command Palette.If you need a more complete way to view the Git history in VS Code, install the GitLens extension.
Ctrl
+ Shift
+ X
on Windows or Linux.Command
+ Shift
+ X
on macOS.Make sure to install the correct GitLens extension as shown in the screenshot.
You can click on the Source Control icon in the Activity Bar on the left to view the commits and the file history using the GitLens extension.
If you click on a specific file a git diff between this and the previous commit is shown.
You can also press:
Ctrl
+ Shift
+ P
on Windows and Linux.Command
+ Shift
+ P
on macOS.F1
to open the Command Palette.You can right-click on a file in Explorer and select Open File History.
You can also right-click on a folder in Explorer and select Open Folder History.
You can also use the Git History extension to view the Git history in VS Code.
Ctrl
+ Shift
+ X
on Windows or Linux.Command
+ Shift
+ X
on macOS.Make sure to install the correct Git History extension as shown in the screenshot.
The extension can be used to:
Once the extension is installed:
Ctrl
+ Shift
+ P
on Windows and Linux.Command
+ Shift
+ P
on macOS.F1
to open the Command Palette.For example, you can select the Git: View History (git log) command to view the commit history for each branch for all or specific authors and look at the graph.
The Git: View File History command displays the commit history for the selected file.
The Git: Line history command displays the commit history for the selected line or code block.
Once you open a file, you can also click on the Git: View File History icon to view the file's commit history.
Clicking on the icon opens a new Window that shows the file's git history.
I've also written an article on how to undo the last Git commit in VS Code.
You can learn more about the related topics by checking out the following tutorials: