Undo pending changes on a file in Team Foundation Server

Ralph Jansen BlogIn this small tutorial I will explain how to undo pending changes on a file on your Team Foundation Server. I tested this code on a Team Foundation Server 2010 edition.

First you need the name of the workspace that is locking your file on the server. To accomplish this you can run the following code in the Visual Studio Command Prompt:

tf workspaces /owner:<developers_logonname> /computer:* /server:<your TFS server>

After you have found your workspace name, you can undo the changes for the file with the following code:

tf undo "$/<Path to file to undo>" /workspace:<Workspace name>;<Domain and username> /s:<your TFS server>

 

Note:

  1. Your TFS servername must be with http and the portnumber to succeed.
  2. You can find the path to file simply by clicking the properties on the file in the “Source Control Explorer” window

If you followed the above steps, you will see the following message in the command prompt.
image

One thought to “Undo pending changes on a file in Team Foundation Server”

  1. Another way doing this is by installing the TFS Power Tools. After installing right click on a Team Member in the TFS Team Explorer window and select ‘Show Pending Changes’. Next you select the file(s), right click and choose ‘Undo..’.

    Yet another way is by right clicking on a folder in the TFS Source Control window and select ‘Find in Source Control’. Define your search criteria and when the files are displayed you can select one (or more), right click and choose ‘Undo’.

Leave a Reply