We've all been in the
situation before when a developer goes away for a long weekend (usually
leaving on Thursday) and they forget to check in a file and ensure the
solution builds. Here is how to deal with that in TFS. Unlock the
file according to the instructions found here:
The gist is that running this command will unlock the file:
tf undo /workspace:TheirWorkspace;DOMAIN\TheirUserAccount $/path/to/file
To get a list of workspaces run this:
tf workspaces /owner:DOMAIN\TheirUserAccount /computer:*
Another way to do this:
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 $/Applications/Dev/Branch1/file1.aspx /workspace:”Ra Dev Notebook”;corp1\ra /s:http://altair:8080
(You run this is on a VS client, at the Visual Studio command prompt)
PS: Hope the color coding helped
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.