Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TFS - getting history for specific line of code in Visual Studio

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.

like image 371
Andris Avatar asked Apr 10 '13 14:04

Andris


People also ask

How do I view line history in Visual Studio code?

Open the file to view the history, and then Press F1 and select/type "Git: View History", "Git: View File History" or "Git: View Line History".

How do I jump to a specific line in Visual Studio?

The Go To Line dialog box lets you move to a specific line in the active document. To access this dialog box, open a document for editing, and then select Edit > Go To > Go To Line or press Ctrl+G.

How do I track changes in Visual Studio?

To enable or dai the “Track Change” features, Goto Tools > Options > TextEditor . In General section, you can checked or Unchecked the “Track Change” option . Key Note : While you are using “Track Change” option, you have to select “Selection Margin” display option other wise, “Track Change” Won't work.


2 Answers

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

like image 162
MikeR Avatar answered Sep 23 '22 01:09

MikeR


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.
like image 22
Kelly Cline Avatar answered Sep 25 '22 01:09

Kelly Cline