How do I tell who has files checked out or locked?

Team Foundation Server defaults to shared checkouts. Shared checkouts are great, because they make it a lot less likely you'll be prevented from getting your work done on a project because "Bob has that file locked right now". Checkouts are mostly informational in Team System; they let you know that someone has an intent to edit a file. For example, if you see a file that has been checked out by four other developers, you might opt to work on a different file.

Even though checkouts aren't blocking, sometimes you still may want to know who has files checked out. The command to do this is TF STATUS:

C:\>tf status /user:* /s:http://tsweb:8080

If you don't specify a user, you will only see your checkouts by default. Here, I've specified all users with the star character. And if you're in the project path, you don't need to provide the server name, either.

File name  Change User     Local path
---------- ------ -------- ------------------------------------------
$/Demo/ConsoleApplication8/ConsoleApplication8
Module1.vb edit   jatwood  c:\projects\ConsoleApplication8\Module1.vb

$/Demo/MergeConsoleApp/MergeConsoleApp
Scissor.cs !edit  jatwood  C:\Projects\MergeConsoleApp\MergeConsoleApp\Scissors.cs

$/Vertigo.TempusApp/web
web.config edit   jimlin   C:\Inetpub\wwwroot\Tempus21\web.config

Usually pending checkins can be ignored, since they'll eventually be resolved (or undone) by the developer who created the checkout. Note the little exclamation point next to the word edit-- that means an exclusive lock. It's certainly possible for developers to take an exclusive lock on a file via the checkout dialog:

And, of course, binary files like Word documents must be locked because they're unmergable. Thus, there are a few scenarios where you may need to take some administrative action:

  1. a developer leaves your company with a bunch of pending checkouts (or locks). Clean that up all at once by deleting the developer's orphaned workspace. This requires the "Administer Workspaces" permission.

    tf workspace /delete workspace;username /s:http://tsweb:8080
    
  2. A developer leaves a file locked. Unlock it, assuming you have the correct permission. This requires the "UnlockOther" permission.

    tf lock /lock:none /workspace:workspace;username $/folder/file /s:http://tsweb:8080
    

    If merely unlocking the file isn't enough, you can also unlock and undo the pending change, if necessary. This requires the "UndoOther" permission.

    tf undo /workspace:workspace;username $/folder/file /s:http://tsweb:8080
    

posted on Monday, July 24, 2006 11:03 AM by jatwood

Comments

# re: How do I tell who has files checked out or locked?

Also note that "username", above, may need to be in the format "DOMAIN\username", depending on how your TFS environment is set up..
Monday, July 24, 2006 12:01 PM by Jeff Atwood

# re: How do I tell who has files checked out or locked?

You probably know this already, but you can find out who has a file checked out from the GUI. In source control explorer it will usually tell you, but you can also right-click, select properties and the select the status tab.

Obviously, you're gonna need to jump into the command line to unlock it (unless you have the excellent Status sidekick installed from Attrice :-) )
Tuesday, July 25, 2006 2:16 AM by Martin Woodward

# re: How do I tell who has files checked out or locked?

Regarding always locking binary files, there's a trade off with shelving. In particular, no one else can unshelve a pending change to a file that is locked in your workspace. That can prevent having someone (or some thing) else build your changes. It's something to consider, based on how you work.

http://blogs.msdn.com/buckh/archive/2006/01/10/511188.aspx
Tuesday, July 25, 2006 5:56 AM by Buck Hodges

# re: How do I tell who has files checked out or locked?

> You probably know this already, but you can find out who has a file checked out from the GUI.

True, and thanks for mentioning that. In this scenario we wanted a list of everything that everyone has checked out over the entire project (or even the entire Team System server).
Tuesday, July 25, 2006 10:26 AM by Jeff Atwood

# VSTS Links - 07/31/2006

Eric Jarvi on VSTS Tip: teamprise interview

Marcus on MSSCCI Provider update available.

Brian Harry...
Monday, July 31, 2006 6:57 AM by Team System News

# Team System Source Code: Unlocking Checed Out Files

We had a problem recently where one of out developers (a summer intern) left with some files checked
Saturday, September 30, 2006 5:33 PM by Paul Litwin's Blog

# re: How do I tell who has files checked out or locked?

Great tip! If you need to find the name of the workspace, you can bring up properties on the file and click the Status tab. You will get a nice list of the username and their workspace name.

Jeff is awesome.
Thursday, March 22, 2007 3:07 PM by Mike Hanley