TFS: Scorch / Reconcile to ensure source control and the local disk are identical with tfs power tools tftp.exe / tf.exe

Today looking at my tfs workspace I’ve found that its dimension was really huge than the real space that would taken from a clean download of the sources. This of course is because of all the binaries build for debug, release and all the other build configurations, but also from old the files, branches, projects, that are not anymore in the source control, but still in the folder because eventually tfs forgot to remove.

To clean this situation I’ve found the “tfs power tools” really helpful, using the command: tfpt scorch (starting from vs 2017 you can do the same simply using tf.exe so you don’t need to download any extension at all!!)

For Visual Studio >=2017

Just run this command in the root folder of your workspace:

tf reconcile /clean /recursive

Old version of Visual Studio

You can download the Team Foundation Server 2010 + SP1 version from here:

http://visualstudiogallery.msdn.microsoft.com/c255a1e4-04ba-4f68-8f4e-cd473d6b971f

the TFS 2012 version from here:

http://www.microsoft.com/en-us/download/details.aspx?id=35775

the TFS 2013 version from here:

http://visualstudiogallery.msdn.microsoft.com/f017b10c-02b4-4d6d-9845-58a06545627f

and finally the TFS 2015 version from here:

https://visualstudiogallery.msdn.microsoft.com/898a828a-af00-42c6-bbb2-530dc7b8f2e1

Here’s the complete help took from the executable itself (2011 version for TFS 2010 + SP1):

tfpt scorch – Ensure source control and the local disk are identical

Your local disk will be scanned for:
(1) items that are not in source control
(2) items which are different on disk from the workspace version
(3) items which are in the workspace but are missing on disk

Items not in source control will be deleted from disk, just as with the
tfpt treeclean command. Items determined to be different on disk from the
workspace version will be redownloaded from the server. Items missing on
disk will also be redownloaded. Items with pending changes are exempted.

By default, items deleted from your local disk (#3 above) will not be
scanned for, and local items are determined to be identical/different from
the workspace version *solely by examining the read-only bit on the file*.

To redownload items deleted from your local disk (#3 above), supply the
/deletes option. To detect items which are different from the workspace
version but still have their read-only bit set (+R), supply the /diff option.
When using either or both of these options, tfpt scorch runs more slowly.

Usage: tfpt scorch [/exclude:filespec1,filespec2,…] [filespec…]
[/recursive] [/batchsize:num] [/noprompt [/preview]]
[/deletes] [/diff]

/noprompt Do not show the list of items to be deleted and
redownloaded in a dialog box for confirmation
/exclude:filespec[,..] Files and directories matching a filespec in this list
are excluded from processing
/preview Do not make changes; only list the potential actions
/recursive Switch from one level of recursion to full recursion
/deletes Detect and replace items missing from the local disk
/diff Use MD5 hashes to compare items with source control
/batchsize:num Set the batch size for server calls (default 500)
filespec… Only files and directories matching these filespecs
are processed (inclusion list)

I’ve put my workspace in a clean situation, without having any item in checkout, to avoid loosing any changes, then I’ve run this command:

tfpt scorch /recursive /deletes

the /recursive argument will switch from one level of recursion to full recursion, making a deeper analysis
the /deletes argument will also detect missing files from the local disk and replace with the files from the source control.

After the command finish to run, it will be prompted to confirm the changes that will be done.

tfpt scorch deletes
tfpt scorch deletes

Another command that you can use just to remove the files that are not under version control is treeclean:

tfpt treeclean /recursive

tfpt treeclean – Delete files and folders not under version control

Usage: tfpt treeclean [/exclude:filespec1,filespec2,…] [filespec…]
[/recursive] [/batchsize:num] [/noprompt [/preview]]

/noprompt Operate in command-line mode only
/exclude:filespec[,..] Files and directories matching a filespec in this list
are excluded from processing
/preview Do not make changes; only list the potential actions
/recursive Switch from one level of recursion to full recursion
/batchsize:num Set the batch size for server calls (default 500)
filespec… Only files and directories matching these filespecs
are processed

This saved me from a boring time on cleaning scripts, hope you too.

Leave a comment