Thursday, 8 November 2012

Delete Changeset/File in TFS 2010 using the tf destroy command

In quite a few places of our code, for various reasons, that I won't go into, we have passwords stored in the clear (it really would take too long too explain, seriously). Anyway, yesterday I used my own password and foolishly checked-in the file, which meant that my password was available for anybody to see.

I deleted the file and checked it back in without the password, but then I checked the changeset and sure enough the file with my password was there in the changeset. 

I know that what I did was really foolish for various reasons and it is ironic that it happened to me when I have been complaining to anybody that would listen (not many people) that this was a bad idea.

Anyway, after a lot of panicking and Googling, I was resigned to changing my password (This may not sound like too much hassle, but I have the same password on three domains, one of them is production), when I found this command:
tf destroy /?
TF - Team Foundation Version Control Tool, Version 10.0.30319.1
Copyright (c) Microsoft Corporation.  All rights reserved.

Destroys, or permanently deletes, version-controlled items from Team
Foundation version control.

tf destroy [/keephistory] itemspec1 [;versionspec]
           [itemspec2...itemspecN] [/stopat:versionspec] [/preview]
           [/startcleanup] [/noprompt] [/silent]

    Date/Time         D"any .Net Framework-supported format"
                      or any of the date formats of the local machine
    Changeset number  Cnnnnnn
    Label             Llabelname
    Latest version    T
    Workspace         Wworkspacename;workspaceowner
I ran the following command:
tf destroy $/myproj/mypath/myfile.cs /collection:mytfsserverurl
I would suggest running this first, though, which simulates the deletion process.
tf destroy $/myproj/mypath/myfile.cs /preview /collection:mytfsserverurl
I checked the changeset and the file with the password had gone, panic over.

No comments:

Post a Comment