The Usual Tech Ramblings

Reverting a checkout from another workspace

Every now and again, we have issues where a developer will have their laptop rebuilt, and forget they have files checked out in Team Foundation Server (TFS). This isn’t very helpful as sometimes they cannot undo their check outs. Visual Studio doesn’t give you access to undo a checkout in another workspace if it’s not your workspace, however the TF.exe command does. Here’s how:

tf /undo /workspace:workspacename;username $/project/path/to/file

This will happily undo the change on that particular file. If you have a whole directory to revert the changes on, that’s easy too…

tf /undo /workspace:workspacename;username /recursive $/project/path/to/directory

You must remember when reverting somebody else’s change to use the project URL, not the physical path on your local machine, otherwise you’ll get an error like this:

No pending changes were found for <localpathname>\file.aspx

For more details on the tf.exe undo command, see the Microsoft documentation here. Full details on arguments for the tf.exe command can be found here too.