How can I view the Git history in Visual Studio Code?
Asked Answered
W

10

503

I can execute various Git commands from Visual Studio Code, however I couldn't find a way to visualize the history.

Weinberg answered 18/6, 2016 at 17:27 Comment(1)
strangely, it hides in the Explorer tab under Timeline, rather than in the Git tab... :-)Deemster
N
306

I recommend you this extension, Git History by Don Jayamanne

Git History

It does exactly what you need and has these features:

  • View the details of a commit, such as author name / email / date, committer name / email / date and comments.
  • View a previous copy of the file or compare it against the local workspace version or a previous version.
  • View the changes to the active line in the editor (Git Blame).
  • Configure the information displayed in the list
  • Use keyboard shortcuts to view history of a file or line
  • View the Git log (along with details of a commit, such as author name, email, comments and file changes).

repo: https://github.com/DonJayamanne/gitHistoryVSCode

Nigercongo answered 18/6, 2016 at 17:42 Comment(7)
Note that you can download it directly from the marketplace.Vituperation
Git History for VS Code in marketplace marketplace.visualstudio.com/…Receivership
Does this show the history only after you've installed it? Or would you be able to see commands executed before installing it as well (perhaps VS Code stores it somewhere inaccessible)?Churchless
No, I installed it and cannot see the previous history. It shows the history only after its installedOrthotropous
I was using GitLens but found it extremely overwhelming. The interface has just too many options. This, on the other hand, is quite straightforward. Liking it so far.Keck
But, if you faced a issue, like git.viewHistroy command not found , then look here github.com/DonJayamanne/gitHistoryVSCode/issues/238Golliner
You can open the marketplace in VSCode with Ctrl+Shift+X and then search for "git history"Hanson
D
372

You won't need a plugin to see commit history with Visual Studio Code 1.44 or more.

Timeline view

This is a unified view for visualizing time-series events (for example, Git commits, file saves, test runs, etc.) for a file. The Timeline view automatically updates showing the timeline for the currently active editor, by default. You can control this default behavior by toggling the eye icon in the view toolbar. Also, similar to other views, the Timeline view supports find or filter as you type.

The Timeline view is collapsed by default at the bottom of the File Explorer. Selecting the Timeline sash will expand the Timeline view.

enter image description here

[...]

Here is the Timeline view in action:

enter image description here

Declan answered 1/2, 2020 at 0:54 Comment(7)
Can it show branch history? It seems to show selected file history.Gilchrist
@Gilchrist No, for now it is a time-series events (here, Git commits) for a resource (file, folder).Declan
@Declan is there a way in timeline to bring up diff details for then entire commit that the timeline view is showing for a specific file? Is there a way to render "git show <commit id>" view in vsc vs command line vi editor experience?Inattentive
@Inattentive Not that I know of. That would be a good question on its own.Declan
@Declan okay thanks for clarification. While the git history extension mentioned earlier in this thread does provide a way to use ide for view and diff contents of all aspects of a commit in the history log i assumed an oob story would exist for this given timeline is sort of doing this already but at a file scope level. As suggested i created a new SO question for just that issue here.Inattentive
It does not seem to show history for a folder, only for a single specific file.Jurist
Saved my day. When I done git reset --hard I lost a file and wasn't able to restore it through git, so VSCode had the solutionEuphemia
N
306

I recommend you this extension, Git History by Don Jayamanne

Git History

It does exactly what you need and has these features:

  • View the details of a commit, such as author name / email / date, committer name / email / date and comments.
  • View a previous copy of the file or compare it against the local workspace version or a previous version.
  • View the changes to the active line in the editor (Git Blame).
  • Configure the information displayed in the list
  • Use keyboard shortcuts to view history of a file or line
  • View the Git log (along with details of a commit, such as author name, email, comments and file changes).

repo: https://github.com/DonJayamanne/gitHistoryVSCode

Nigercongo answered 18/6, 2016 at 17:42 Comment(7)
Note that you can download it directly from the marketplace.Vituperation
Git History for VS Code in marketplace marketplace.visualstudio.com/…Receivership
Does this show the history only after you've installed it? Or would you be able to see commands executed before installing it as well (perhaps VS Code stores it somewhere inaccessible)?Churchless
No, I installed it and cannot see the previous history. It shows the history only after its installedOrthotropous
I was using GitLens but found it extremely overwhelming. The interface has just too many options. This, on the other hand, is quite straightforward. Liking it so far.Keck
But, if you faced a issue, like git.viewHistroy command not found , then look here github.com/DonJayamanne/gitHistoryVSCode/issues/238Golliner
You can open the marketplace in VSCode with Ctrl+Shift+X and then search for "git history"Hanson
B
120

GitLens has a nice Git history browser. Install GitLens from the extensions marketplace, and then run "Show GitLens Explorer" from the command palette.

Barbarism answered 10/6, 2018 at 18:2 Comment(5)
The latest version of GitLens is really good. It adds a handy sidebar button and allows you to much better visualize changes across multiple branches.Papal
yes, i used that, and i highly recommended that extension because it can show in realtime when i click on some link , ref: academy.byidmore.com/post/…Dyestuff
@JosephSheedy, GitLens seams most popular (downloads) extension for reason.Warp
Good plugin. Did too much overlaying for me. https://mcmap.net/q/12201/-how-can-i-view-the-git-history-in-visual-studio-code built in vscode was exactly what I was looking for.Vulnerable
GitLens > gitHistoryMoses
W
64

It is evident to me that GitLens is the most popular extension for Git history.

enter image description here

What I like the most it can provide you side annotations when some line has been changed the last time and by whom.

Enter image description here

Warp answered 11/6, 2019 at 21:4 Comment(0)
M
50

You don't need an extension to do this, you can just go to Explorer and then Timeline. Timeline in Explorer

If you don't want it in Explorer, you can drag and drop it to the Sidebar, or Source Control or anywhere you want!

in sidebar

If you want more fancy features like visualizing and all that stuff you need an extension.

Mellen answered 31/8, 2021 at 17:8 Comment(1)
Timeline only shows the log for a single file, not the branch.Palmary
P
49

I would recommend using Git Graph extension.

Purgatory answered 28/5, 2019 at 18:9 Comment(1)
Simple and efficient.Microbarograph
Z
35

I strongly recommend using a combination of GitLens & GitGraph.

Below snapshot highlights how gitlens is showing commit over time

enter image description here

And the below picture is for the the amazing vivid GitGraph

enter image description here

Zaidazailer answered 18/10, 2020 at 0:18 Comment(0)
S
15

Git Graph seems like a decent extension. After installing, you can open the graph view from the bottom status bar.

Shod answered 20/5, 2019 at 15:32 Comment(0)
S
2

You will find the right icon to click, when you open a file or the welcome page, in the upper right corner.

Enter image description here

And you can add a keyboard shortcut:

Enter image description here

Stirps answered 8/11, 2018 at 12:45 Comment(3)
JIC: ... before to see this option, you need to have Git History extension previously installed.Koo
Can you update your answer with the prerequisites (after testing it is actually the case)?Rotl
Thanks @Jhegs, somehow I forgot about reinstalling that extension and was looking for this feature everywhere in the settings 🤦‍♂️Brandes
L
2

There's another comfortable way to navigate the commit history for a file in Visual Studio Code by using the Gitlens extension.

That provides two functionalities, "File history" and "Line history", that are accessible from the VCS menu once Gitlens is installed.

Full explanations with example and doc reference provided in this answer.

Lehman answered 1/2, 2023 at 10:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.