44

Is it possible to get history for specific line of code in Visual Studio, when using TFS as source control?

Before I used another source control (Vault), and I was able to get history for line of code and check who added/modified it. It looks like TFS lacks such functionality. Are there any reporting tools that can do this.

I'm using Visual Studio 2010 with TFS 2010.

Martin
  • 3,396
  • 5
  • 41
  • 67
Andris
  • 1,262
  • 1
  • 15
  • 24
  • I trust you're talking about the Blame or Annotate command in Vault? – Edward Thomson Apr 10 '13 at 14:39
  • Often times, there are many branch and merge changes that make it hard to find when the line of code was last _authored_. That is what I am ultimately looking for. – mek363 Jul 28 '16 at 19:57

3 Answers3

49

As far as I know, there is nothing like the complete history of one line, which could be very confusing and hard to identify for a version control. Nevertheless, TFS can show you who change the specific line the last time. Two ways to get this:

  1. Browse in Source Control Explorer to the file, right click it and in the middle of the context menu, you will find the option Annotate, which will show it to you.

  2. Open the file you are interested in. Right click somewhere in the edit pane and choose Source Control -> Annotate

Endy Tjahjono
  • 24,120
  • 23
  • 83
  • 123
MikeR
  • 3,045
  • 25
  • 32
  • 5
    This only shows the last change made to that line. Often you want go go deeper, for example if the last change was of cosmetic nature – doublehelix Aug 29 '16 at 06:23
14

This is tedious, but it works, if you are desperate: You have a line whose history you'd like to trace.

  1. Find the file in TFS Source Control Explorer, right click, view history.
  2. Select the next-to-most recent Changeset, right click, select Changeset Details.
  3. Find the file in Changeset Details, right click, select Annotate.
  4. THIS IS IMPORTANT: Annotate shows the most recent changeset for each line AT THE TIME OF THE CHANGESET. (This is why you start with next-to-most recent Changeset.) Find the line in which you are interested. The changeset and author is noted.
  5. If this isn't enough, go back to your history view and find the changeset thus noted.
  6. Again, select the previous changeset, right click, select Changeset Details. Repeat steps 3-6.
Kelly Cline
  • 2,206
  • 2
  • 33
  • 57
4

You can also just right click the file in the Solution Explorer and select Annotate.