Unlock Files in TFS Source Controller Locked by a User Who Has Left or Forgot to Check In Code

Understanding Locked Files in TFS

Following are the steps To Unlock files in TFS source controller 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
Unlock files in TFS source control

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

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

Unlock files in TFS source control

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 a TFS file that a user locked and then either forgot or changed their computer.

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 
Unlock files in TFS source control
  • Launch the TFS Administration Console on the TFS server.
  • Navigate to Team Project Collection > Version Control.
  • Locate the locked file and right-click it.
  • Select Unlock or Undo Pending Changes.
  • Confirm the action to remove the lock.

Method 3: Using Visual Studio Source Control Explorer

If you have admin privileges, you can unlock files directly through Visual Studio:

  • Open Visual Studio and connect to the TFS server.
  • Go to Source Control Explorer.
  • Locate the locked file.
  • Right-click on the file and select Unlock.
  • If the option is unavailable, ensure you have the necessary administrative rights.

This method is best suited for administrators who have permissions within Visual Studio.

Best Method 5: Reassigning or Deleting the User’s Workspace

If the locked files belong to a user who has left the organization, administrators can either delete or reassign their workspace.

  • Open the TFS Administration Console.
  • Navigate to Workspaces.
  • Locate the workspace associated with the user.
  • Choose Delete to remove the workspace, unlocking all associated files.
  • Alternatively, reassign the workspace to an active user, allowing them to check in or undo changes.

Best Practices to Prevent Future Lock Issues

To avoid recurring file lock problems in TFS, consider implementing these best practices:

  • Use Shared Checkouts: Allow multiple users to check out the same file when possible.
  • Regularly Audit Workspaces: Periodically review and remove inactive workspaces.
  • Set Auto-Unlock Policies: Configure policies that unlock files automatically after a set period of inactivity.
  • Educate Developers: Train team members on proper check-in/check-out procedures.
  • Assign Backup Administrators: Ensure there is always an admin with permission to unlock files.

Conclusion

Read Also

Gitlab Error-500 Login for 2FA users fails after a restore

Previous Post
Next Post

Leave a Reply

Your email address will not be published. Required fields are marked *