15

Is it possible in VSCode to show git history for a range of line ?

Let's say I have 1000 commits concerning this file, and a range of line in this file had its last change on commit 24, I have to check 976 commits in the editor.

I saw something related here, but is it possible directly in the IDE?

torek
  • 448,244
  • 59
  • 642
  • 775
Benjamin Barrois
  • 2,566
  • 13
  • 30

2 Answers2

5

You can see the commits related to only a set of lines 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.

In the "File history" tab you can see all the commits related to the currently viewed file, whereas in the "Line history" tab you only see the commits related to the currently selected lines.

Example below:

enter image description here

This is the gitlens documentation reference.

mattiatantardini
  • 525
  • 1
  • 5
  • 23
  • Just a comment, I don't see the "Line History" panel in GitLense 13 Free version, VSCode version 1.75.1. The settings file does have the line `gitlens.views.lineHistory.enabled`, but it says that this setting is deprecated and not used. In my case the "File History" is good enough, but I doubt its little drop list can handle 1000 commits. Which is unfortunate. Imho, this is exactly the feature for GitLense inside VSCode. I don't think that just committing stuff inside VSCode is that useful. – xealits Feb 14 '23 at 12:57
  • 2
    weird, I have vscode 1.75.1 and gitlens 13.2.0 and it works fine. You may try to right-click on another tab of the VCS menu, like file history, tags or branches, and see if you can check the line history option. That is the way I discovered it. Anyway, I don't know if this feature can handle so many commits, but I think it may be useful in many situations. – mattiatantardini Feb 14 '23 at 15:05
  • 1
    you are absolutely right, it is in the right-clicked list! thanks! Indeed, this is a perfect git feature for a text editor. Most often I just need to look up how the line changed from the previous commit. – xealits Feb 15 '23 at 16:39
0

I'm not aware of a way to do exactly what you ask for; and I'm not sure if it's at all possible (or what the exact semantics of it would be).

The closest workaround for me is to use the GitLens VSCode extension and specifically its Blame functionality.

myke
  • 479
  • 3
  • 14