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
/s:[server path]
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]
February 24, 2009 at 6:36 pm
You show the seperator for user’s workspace and user name as a colon, but its actually a semi-colon. Using a colon throws an error.
tf undo [/workspace:workspacename[;workspaceowner]] [/server:servername]
Other than that, thanks a bunch for the article! Answered my problem perfectly.
September 9, 2010 at 8:44 am
Thanks,
I’ve followed your advices and worked.
Cheers,
Catalin
April 15, 2011 at 8:17 pm
Thanks, it worked!, and yes, you have to use a semicolon instead of a colon in the workspace parameter
July 12, 2011 at 7:35 pm
That was helpful.Thanks!
November 1, 2011 at 6:04 pm
Thanks.
Just to let you know that “tf lock /lock:none” will not work for items that need to be checked out exclusively. You have to use “tf undo” in those cases.
October 8, 2012 at 5:51 am
Thanks a lot! Helped me unlock my own files from a different computer (a different workspace)
November 4, 2012 at 9:50 am
Hi there, I do think your blog could be having web browser compatibility
issues. Whenever I take a look at your web site in Safari, it looks fine but when opening in IE, it has some overlapping issues.
I merely wanted to give you a quick heads up!
Besides that, excellent site!
January 2, 2013 at 10:31 pm
I have learn a few good stuff here. Definitely value bookmarking for
revisiting. I surprise how so much attempt you place to make any such
magnificent informative web site.
February 5, 2013 at 4:19 pm
We are a group of volunteers and starting
a new scheme in our community. Your website provided us with valuable information to work on.
You have done a formidable job and our entire community will be grateful to you.
March 18, 2013 at 10:50 pm
Hey I know this is off topic but I was wondering if you knew of
any widgets I could add to my blog that automatically tweet my newest twitter updates.
I’ve been looking for a plug-in like this for quite some time and was hoping maybe you would have some experience with something like this. Please let me know if you run into anything. I truly enjoy reading your blog and I look forward to your new updates.
May 3, 2013 at 12:40 am
Its been a long while since I was able to encounter a competent post similar to this.
I am excited on what your upcoming work will be.
A big heads up for such an incredible job.
May 17, 2013 at 1:24 pm
I don’t often leave feedback on any article however this
article captured my attention, I have to put
a remark. I have to proclaim this article is well
written. No unwanted words and is honest