One of the rare but critical tasks of Configuration Management is the unlocking of items locked or checked out by someone else, like an ex-employee or a developer in the Bahamas while an emergency patch needs to be pushed out.
Unfortunately, the unlock action is not available in the context-menu or a GUI but needs to be executed from a command line. I wonder why it’s not in the GUI, granted deleted files and pending changes will not necessarily be visible in the GUI but at least the Undo should be available for visible items while the command line still provides the all-encompassing functionality.
The help was not very clear, so I’ll simplify the command for you.
There are 2 possible options for unlocking, viz. unlock or undo (if checked out for Edit).
The respective command to use is tf lock /lock:none or tf undo
The parameters in both cases are the same:
filename (in the help topic, this is the itemspec parameter)
This is the file you want to unlock
/workspace: [user’s workspace];[user name]
The user’s workspace needs to be figured out…by right-clicking the locked item and selecting Properties… and then the Status tab
The user name is the fully qualified user name, in the form: domain/user
This is the TFS server in question. Typically it’s http://servername:8080/
So, a sample command would be something like:
tf undo $/Apps/Dev/file1.aspx /workspace:”Dev station”;corp1\ra /s:http://altair:8080
(You run this is on a VS client, at the Visual Studio command prompt)
Another command I found useful during the process was tf status /user:Joe /s:server path, which essentially lists all files locked by Joe. I piped it to a text file (with >> C:\joe.locked.txt) to get a report.
[edit – changed colon to semicolon above. Thanks for the feedback]