Microsoft

Blog Categories

Subscribe to RSS feed

Archives

Team Foundation Server – Undo Check Out

On various projects, there are occassions when files are left locked by team members leaving the project or while on long vacations. In VSS, the administrator could simply select the file(s) and chose to undo-checkout.
A couple of months ago, our TFS installation was moved from one domain to another and some files were locked out with user accounts from a domain that was retired. Well, being the admin, I thought it was just a matter of selecting the files and unlocking them. Well, guess what – the option either didnt show up or when it did, it was grayed out. After researching this, I found out that the way to unlock, undo-check out is using the command line options:

1. Check the status of the file in question

c:tf status "$/ProjectRoot/Project/File" /server:<servername> /format:detailed
2. Since we need to know the name of the workspace for the next few commands, the following command will give us this information
c:tf workspaces /owner:<domain><userid> /computer:* /server:<servername>
3. Unlock the ‘locked’ file
c:tf lock /lock:none "$/ProjectRoot/Project/File" /workspace:<workspace-name>;<domain><userid> /s:<servername>
4. If required, undo the changes using the following command
c:tf undo "$/ProjectRoot/Project/File" /workspace:<workspace-name>;<domain><userid> /server:<servername>
For each of the above commands, you need to have the correct administrative rights on the project/TFS server.
Hope this helps others in similar situations. I am not sure why this is not clearly documented.

Leave a Reply