There may be times when you remove file by mistake and need to restore a most up to date copy of this file into the TFS Source Code repository. This task can be accomplished with the help of the TFS command line tools.
In order to recover file we need to run following line of code tf dir $//deleted command. This statement will give you a list of deletion IDs for all versions of the file. Once this command line has been ran, you will see the following output
This list of files will give us good idea about the file that we want to recover. Once we determine versin of the file that we want to recover we run the following command line
tf undelete projectFile1.cs;X3
X3 is the version that we want to restore and as it was specified in our original, we are restoring most up to date file. This command will restore this file into the folder that this file was deleted from. It will copy this file into the current workspace that we are working in currently.