How to unlock files in TFS source controller locked by user who have left or forgot to check in code

  • Post author:
  • Post category:How-To
  • Post last modified:December 14, 2022

We have to Undo Checkout ,Unlock Pending Changes or delete workspace in TFS with TF  Command, of other Developer’s Workspace using Team Foundation Server

We are using the Team Foundation Server 2019 (TFS) as our source control and I have faced the necessity to undo pending changes or tfs undo pending checkins on an other developers computer or workspace with administrator rights.

A few times ago, one developers among the developer team has check-out the code files and forget to check in the source files.

Following are the steps To Unlock a file or Remove workspace:

1- Open a developer command prompt:

  • Go to Start->All Programs-> Visual Studio 2017(or depending on your version of Visual Studio)->Developer Command Prompt for Visual Studio
  • Open Developer Command Prompt for Visual Studio

2- How to find workspaces available on Source controller (TFS)

tf workspaces /server:http://applikazo:8080/tfs/Collection_Name /owner:*

3- How to find workspace of the user/employee who left company or forgot?

tf workspaces /server:http://applikazo:8080/tfs/Collection_Name /owner:asad

4-  How to Undo the changes made by user over TFS file?

tf undo $/Cosmos2008/Cosmos/OctopusWeb/Test/Eralper/EY.aspx /workspace:DESKTOP-k8hv7h7; asad /collection: http://applikazo:8080/tfs/Collection_Name 

5- How to unlock TFS file which was locked by user and forgotten or user computer changed?

tf lock /lock:none /workspace:DESKTOP-k8hv7h7;asad $/Cosmos2008/Cosmos/OctopusWeb/Test/Eralper/EY.aspx/collection: http://applikazo:8080/tfs/Collection_Name 

6- How to remove workspace in TFS with below command, locked by employee/user?

   tf workspace /server:http://applikazo:8080/tfs/asad /delete DESKTOP-k8hv7h7;asad 

Hopefully, The above mentioned commands will be helpful  for other developers who want to 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.

 

 

Leave a Reply