How to unlock files locked by employee who have left the organization?

Developers always checkout lots of files to their local machine, work on them and then check them into the source control. But what happens when someone checked out bunch of files, modified them and then suddenly left the organization without checking them in?

This can be a night mare for other developers who wants perform some task on those files but they can’t access the file because it has already been checked out and sitting in the workspace of someone else’s machine. You can neither delete, edit nor even delete or rename the folder containing them. This can be really frustrating when you have a deadline to meet.

In order to release a lock you can either unlock the files if you know what files are locked or better, you can remove the workspace of the developer who has left the team. When you remove the workspace, all the files and folders checked out by it’s owner will be checked in into the source control.

To Unlock a file or Remove workspace follow below steps:

  1. Open a developer command prompt:
    • Go to Start->All Programs-> Visual Studio 2013(or 2012, depending on your version of Visual Studio)->Visual Studio Tools
    • Open Developer Command Prompt
  2. Find out the workspace of the employee who left the organization by running below command. (username is for the employee who left)
    • tf workspaces /owner:<username> /collection:<collection url>
    • Ex: tf workspaces /owner:kindian06 /collection:http://kptfs:8080/tfs/DefaultCollection
    • This command will list all the workspace of that user.
  3. To undo the changes made to a file use below command
    • tf undo <filename with complete path> /workspace:<workspace name>;<username> /collection:<Collection Url>
    • MSDN Link for undo command
  4. To unlock a file:
  5. To remove a workspace: