ShareThis

Unlock TFS Files Locked by Other Developers

It is a common experience that someone needs to unlock a file, locked in Team Foundation Server by another developer at a moment that the developer who locked the file is not available to unlock it. Same thing happens if the original login used for lock a file is no longer exists. For the both cases one solution would be the use of 'tf undo' command from Visual Studio command prompt. The undo command removes any locks so that other developers can check out the file. It should be noted that you should have enough privileges to execute this command. Command syntax is:

tf undo /Projects/Project1/Controls/FileName.cs"
/WORKSPACE:Dev123;Domain\UserName /s:http://tfs01:8080 /recursive

Here the Workspace and the User are the ones who locked the file. This information can obtain from source control explorer. If you want to find list of files locked by a developer use the 'tf status' command.

One important thing to remember when using 'tf undo' command is, you may have to use server name as "http://…" if you are executing command from a developer box. Otherwise you will get the ‘cannot find server’ error message for server name as well as for IP address though you are in the same domain, etc. By using server name as a URL it will uses web services to invoke the command.

You can read more detail about “Tf Command Line Utility Commands” from MSDN here.