Sometime we need to do undo checkout from other user’s workspace in Team Foundation Server (TFS). Here is the procedure to do it using Visual Studio’s Command Prompt.
Open the Visual Studio Command Prompt and type the following command:
tf undo /workspace:"WorkspaceName;WorkspaceOwnerName" $/Project/SomeFile.aspx
Replace the workspace and workspace owner’s name and also path of the file to undo checkout.
You must have “Undo other users’ changes” permission to perform this. When you will execute this command it might prompt for your TFS credentials (if those were not saved/remembered).
Tip: You can use the above command to undo checkout a file from your own workspace.
Tip: To get the workspace and owner names and file path, try to check out the same file in Visual Studio it will provide this information in output window, copy from there and replace in the above command and execute it.
Tip: You can undo check out all the files in project or specific directory by add /recursive parameter in the command, please see the example below:
tf undo /workspace:"WorkspaceName;WorkspaceOwnerName" $/Project /recursive
tf undo /workspace:"WorkspaceName;WorkspaceOwnerName"...