I need to show TFS history of a file on the command line so I can redirect to a text file.

Problem:

When I run the tf history command from the command line it shows a dialog box.

Solution:

Add the /noprompt option to the TF History command. This will cause the output to be shown in the command window. You can then use DOS redirection to easily store the results in a text file.

For example:


tf history $/MyProject/Main/Source /recursive /noprompt /format:detailed /collection:http://MyTFS:8080/tfs/defaultcollection > history.txt

This will result in a new file called history.txt to be created in the working folder.

Explanation:

The key to not showing the dialog box is the /noprompt.  If you leave off the /noprompt you will be shown a dialog box.


The output redirection operator > is used to send the command output to somewhere other than the screen for example a text file.


> somefile.txt (If the file already exists it will be overwritten.)
>> somefile.txt (This will append a file. If the file does not already exist it will be created.)

Comments are closed