What do you do if a file in TFS is locked by someone else?

Someone left the organization, but before leaving, he locked all the files for an unknown reason.

How do you unlock them all so that other developers can work?

+58
command-line version-control tfs administration
Nov 06 '08 at 14:28
source share
11 answers

For the next operation, you will need either the project administrator for the project you want to unregister, or the Team Foundation administrator if you want to do this in all projects.

If you still have a username, you can simply do something like this:

  • Open a Visual Studio command prompt (Start β†’ Programs β†’ Microsoft Visual Studio 200X β†’ Visual Studio Tools β†’ Visual Studio 200X Command Prompt)
  • Run the following command:

tf lock / lock: no / Workspace: WorkspaceName; USER_NAME / recursive $ /

To get a list of workspaces for the user, simply run the following command from the same prompt:

tf workspaces / owner: username

For additional commands, select the tf /?

+56
Nov 06 '08 at 14:28
source share

If the developer left the organization, it is best to delete their workspaces. This will unlock files for you, but also free up some resources on the server.

See the next blog post I made on this topic when it happened to me a few years ago.

http://www.woodwardweb.com/vsts/unlocking_files.html

You can either delete the workspace using the command line (tf.exe), or use the attribute

+33
Nov 06 '08 at 14:48
source share

This was the only way to solve this problem, which was to delete the user's workspace.

If the error message says "The element $ / ... is locked to retrieve someUser: 1 in the workspace someMachine123." then i use the command:

tf workspace /delete /server:http://machinename:8080/tfs/DefaultCollection someMachine123;someUser:1 

There is only one space between the collection URL and someMachine123;someUser:1 .

Please note that I drew attention to the fact that in the error message the user is referred to as someUser:1 , so I imitated this in the command. It is not enough just to run the command with someUser only. I'm not sure what it means: 1, but the bottom line is, imitate the error message.

Please note that the full path to the collection must be specified on the server, which can be found by going to the Administration Team Foundation Server Console-> Tier Application> Collections of the team project, the bottom panel will show the URL for the collection selected in the top panel .

I also had a problem because I accidentally tried to use the plural of workspaces instead of just workspace , because there is a similar command that is plural.

+7
Aug 29 2018-12-12T00:
source share

first you need to be entitled to it. If you have one, it’s easiest to use third-party TFS users from attrice http://www.attrice.info/cm/tfs/

+6
Nov 06 '08 at 14:31
source share

I needed to add / collection: collectionURL, otherwise the workspace was not found:

  • List item

tf loc / lock: none / workspace: WorkspaceName; UserName / collection: collectionURL

+1
Sep 17 '14 at 13:49
source share

The following is an explanation of using TFS permissions.

With Unblock Other User Changes, permission requires permission to remove the lock held by another user.

0
Nov 06 '08 at 14:31
source share

The system administrator has reset that user password, log in as this user, unlock all files ...

I would think that this solution is for almost everyone who no longer belongs to this organization ...

0
Nov 06 '08 at 15:03
source share

It is better to remove the workspace of this user from the server. Example

tf workspace / delete / server: workspace your_tfs_server; Username

0
Jul 22 '14 at 20:12
source share

Sometimes this disguises a different problem when a completely different application is blocked by another user, but you can’t even create a new folder for a new project that you want to join (the goal will not allow you to create and incorrectly indicate that someone has a file blocked from them name), but then you dig deeper, and another project is the culprit.

Thus, a completely different project may be a problem with the files being locked by someone else.

0
Jan 20 '16 at 23:44
source share

The method that helped me, my account has administrator permission for TFS and the project:

In Visual studio 2015:

  1. Go to Team Explorer
  2. Click right on your solution and select Open in version control system. Exporer
  3. Left right click on your solution
  4. Select Advanced
  5. Select Block ...
  6. Left right click on your solution
  7. Select Advanced
  8. Select Unlock (you can now choose an unlock)

Right now, every developer can easily commit their changes :)

0
Mar 05 '19 at 11:09 on
source share

Use this solution as a last resort .

Im using TFS 2012. I went to the TFS database and ran the following queries. And it worked! Of course, be very careful when you mess with the database, make backups, etc.

The database is called Tfs_ <<your_TFS_collection_name β†’. Ignore the MSSQL Tfs_Configuration database. I'm not sure, but if you do not have a Tfs_ <<your_TFS_collection_name β†’ β†’ database, the settings can be in the Tfs_DefaultCollection database. Locks are stored in tbl_PendingChange.LockStatus.

 /*Find correct row*/ SELECT LockStatus, PendingChangeId, * FROM tbl_PendingChange WHERE TargetServerItem like '%<<fileName>>%' /*Set lock status to NULL (mine was set to 2 initially)*/ UPDATE tbl_PendingChange SET LockStatus = NULL WHERE TargetServerItem like '%<fileName>>%' AND PendingChangeId = <<PendingChangeId from above>> 
-3
Apr 20 '16 at 23:21
source share



All Articles