10
votes

How do I view all unversioned/uncontrolled files using TFS 2010 and VS 2010?

The problem that I am currently running into is after creating a new controller and view using the context menu (MVC3) I decided to roll back all those files by undoing the add in my pending changes window. I found that the files were no longer in TFS but are still on the disk. I would like to see the files that are currently on the disk but not versioned by TFS.

This is trivial in Subversion and Git (these files will always appear unless told to explicitly ignore them) but I am not seeing an option to view these in TFS - they do not appear under in my Pending Changes view. I am new to TFS so I assume I am just missing something.

4
Can you give an example of what you're trying to accomplish? I don't understand.DevinB

4 Answers

18
votes

If you are trying to determine all of the files which exist on your filesystem within a project folder that are NOT in TFS,

  1. Open visual studio

  2. Open Team Explorer (ctrl-w, m)

  3. Go into "Source Control"

  4. Navigate to the folder you want to find the unversioned files within.

  5. In the top bar there is an icon with two folders and a magnifying glass between them, hinttexted "compare folders"

    enter image description here

  6. Compare "Source Path:" of whatever it suggests (probably server version) against "Target Path:" of your local version.

It will highlight all the differences within those folders. Any files which exist in the right hand (local) column are files which are not currently stored in TFS.

7
votes

Team Foundation Server does not delete files when you undo the pending add for them - this is to prevent possible data loss. (It's possible, for example, that you want to create a file locally but not check it in to Team Foundation Server - since Visual Studio and Eclipse automatically pend this file as an addition, if it were to remove the files when you undid the add then there would be no way to have a file locally that didn't exist on the server.)

The Team Foundation Server power tools have to different operations that will help you sync up your local workspace with the server.

If you have files on disk that are not on the server and you want to update them (push them to the server), you can use tfpt online. This will detect all the files that were added or modified locally and create new pending changes to update the server. This is particularly useful if you've been working disconnected from the server and want to pend those changes.

If you have files on disk that you want to remove or otherwise update with the latest server version, you can use tfpt scorch. This will detect any files that have been added, modified or deleted locally and allow you to update them with the latest server version. If you just want to see the list of files and not actually take any action automatically, there is a preview mode you can use with tfpt scorch /preview.

2
votes

Assuming that you have PowerShell installed, and tf.exe (from TFS Explorer tools) and sed.exe (GNU Tool) in your path, you could use this script (PowerShell) to do the work:

if((tf prop .) -ne $null) {
  tf folderdiff . /r /view:targetOnly /noprompt | sed -e '/^=\+$/,/^=\+$/d; /^$/d' | %{
    if(Test-Path $_) {
      rm $_ -Rec
    }
  }
}
0
votes

Actually, an pretty easy way to remove files/folders from your file system is to simply delete (or move) the local project folders then do a "get specific version" from TFS. Be sure to check both of the "overwrite" checkboxes.

It will then pull down everything that is currently stored in TFS.