13

I use Visual Studio 2019 and I am missing a feature I can't find in the settings. In Visual Studio Code, once I open a project that is under git control, I see an author and commit info of the line the text cursor is currently located in. If I open the same project in Visual Studio 2019 this functionality does not appear.

I am looking for the info between line 8-9: enter image description here

Is there any option to active that feature from VS Code in VS 2019 as well? Any help is highly appreciated!

Daniel Stephens
  • 2,371
  • 8
  • 34
  • 86

3 Answers3

14

If you want source control history at the method level, enable CodeLens. Note that the 2019 community version of Visual Studio does not include this feature.

If you want source control history at the per-line level, in your text editor, right click > Source Control > Blame (Annotate):

Visual Studio Blame(Annotate)

Author and commit (git blame) info will be displayed for each line:

Visual Studio annotations

For quicker access, add a shortcut for the command "Team.Git.Annotate".

JeremyTCD
  • 695
  • 1
  • 6
  • 11
  • 2
    Hi, correct, that already works! But I was looking for the view "inside" the text editor – Daniel Stephens Mar 29 '20 at 17:10
  • Like here between line 8 and 9. https://thepracticaldev.s3.amazonaws.com/i/auirs5ju4otnj93ctivh.png – Daniel Stephens Mar 29 '20 at 17:11
  • Is [CodeLens](https://learn.microsoft.com/en-us/visualstudio/ide/find-code-changes-and-other-history-with-codelens?view=vs-2019) what you're after? The source control part of it is not available in VS community. – JeremyTCD Mar 29 '20 at 22:47
  • Yes!! That's it! Thanks! I activated it, but no change. I use VS2019 Professional – Daniel Stephens Mar 30 '20 at 04:48
  • 1
    Sure! I've amended my answer with the solution. I'd suggest including the "thepracticaldev" image in your question, it adds clarity and would be helpful for future visitors. – JeremyTCD Mar 30 '20 at 05:37
  • Thank you very much!! But unfortunately that's still not what I need :-( Check again my screenshot. The view is very different to the Blame View. It only displays it for the current selected line – Daniel Stephens Mar 30 '20 at 13:21
  • According to https://developercommunity.visualstudio.com/comments/853220/view.html it should work. You could try opening an issue there! – JeremyTCD Mar 30 '20 at 16:27
  • What may be the reason I don't have the "Source Control" sub-menu in the context menu? Although I can find and enable it using the Quick search (it called "Git > Blame(annotate)"). – David Ferenczy Rogožan Jan 14 '21 at 14:00
  • In recent versions "Source Control" has been renamed to "Git" in the context menu. – JeremyTCD Jan 15 '21 at 01:44
7

In Visual Studio Professional 2019 using GIT as source control you should be able to right click in the file and select Git > Blame(Annotated) to view line annotations with author, date and a unique commit identifier.

Clicking the commit id will bring up the change set so you can review all of the changes associated with the line(s) in question as well as any comments for the commit.

It threw me off because a person might think to right click in the file and select Annotation > Show Line Annotations which did not seem to work for me.

Dharman
  • 30,962
  • 25
  • 85
  • 135
Allen Tellez
  • 1,198
  • 1
  • 10
  • 14
  • I only noticed this feature after installing the GitBlamer extension. Not sure whether this extension was responsible for the Git checkin display in the left hand margin next to the file in VS.NET 2019 Community. – CAK2 Jun 04 '21 at 20:25
2

I was recently checking out other Source Control options (Perforce and Plastic SCM), and then noticed I too had lost my Git ▸ Blame option in VS. Turned out the Plug-in Selection was no longer set to Git, so make sure it is on inside of Tools ▸ Options. Source Control Settings

Dover8
  • 607
  • 3
  • 17