Did your fellow broprogrammer leave for the day? Did you reformat your virtual machine or development workstation? When a file gets checked out in TFS, it gets associated not only to a user, but to his/her workspace (the machine/source code folder they are on). That makes it slightly more difficult to regain access to the file and undo their checkout so that you can take over.
This task is not uncommon and has been blogged about. Huge thanks to Richard Murillo for documenting it in an MSDN blog here: http://blogs.msdn.com/b/rimuri/archive/2006/03/06/544686.aspx
The date of that post is 2006, so here we are 8 years later. Allow me to regurgitate it for you, with full credit to Richard, just in case that post gets removed.
- Open Visual Studio Command Prompt by going to Start –> All Programs –> Microsoft Visual Studio (whatever version you are on) –> Visual Studio Tools –> VS Command Prompt (name may vary).
- You will need to know the workspace name. The easiest way to do this, because doing it as documented in the blog post above, may return a lot of results to sort through, is to attempt to get an exclusive lock on it by doing a check out. You can right-click and click “Check-out for Edit…” and set Lock type to “Check Out – Prevent other users from checking out and checking in”
If you look at your output window, you will see the following message:
TF10151: Cannot lock item $/path/file.ext for check-out. The item $/path/file.ext is checked out by Gates, Bill in workspace REDMND-GATESBILL-D.
- Now that you know the workspace, path, and user, you can just run the following command to undo checkout:
tf undo /workspace:REDMND-GATESBILL-D;MSFT\GatesBill $/path/to/file /s:http://your-tfs-server:port/
- If you need to delete the entire workspace and changes, in the event the person left the company, you can also do so with the following command, but note that you will be deleting any unsaved/checked-out changes:
tf workspace /delete REDMND-GATESBILL-D;MSFT\GatesBill /s:http://your-tfs-server:port/