Undo Checkout from Other User’s TFS Workspace

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:
Example 1

tf undo /workspace:"WorkspaceName;WorkspaceOwnerName" $/Project /recursive

Example 2

tf undo /workspace:"WorkspaceName;WorkspaceOwnerName" $/Project/SomeDirectory /recursive

Note: “WorkspaceName;WorkspaceOwnerName” is given it quotation marks, most of the documentation and tutorials don’t mention it but your command couldn’t be executed successfully if you don’t wrap it in quotation marks.

Comments
Share it

2 thoughts on “Undo Checkout from Other User’s TFS Workspace

Leave a Comment

Your email address will not be published. Required fields are marked *