So a teammate of mine changed jobs recently, and left a little bit of mess behind on TFS (our team uses TFS Preview). Pending changes including adding package items with exclusive lock. As I’ve been looking for an information on how to drop his pending changes, it turned out quite easy to perform for existing files (change type: edit, lock), yet not for all new files (change type: add, lock).

Here’s a bunch of commands you can run on your local dev machine from the Visual Studio Command Prompt. You need to have admin rights on TFS for the project in order to do something more than listing.

LIST WORKSPACES OWNED BY user@domain.com

tf workspaces /owner:user@domain.com
              /collection:https://yourproject.tfspreview.com/defaultcollection

LIST ALL PENDING CHANGES IN WORKSPACENAME;user@domain.com

tf status $/PROJECTNAME/* /workspace:WORKSPACENAME;user@domain.com
          /collection:https://yourproject.tfspreview.com/defaultcollection
          /recursive

UNDO ALL PEDING CHANGES IN WORKSPACENAME;user@domain.com

tf undo $/PROJECTNAME/* /workspace:WORKSPACENAME;user@domain.com
        /collection:https://yourproject.tfspreview.com/defaultcollection
        /recursive

References