Undoing a checkout that belongs to another user


Since we shipped, we have gotten a lot of questions but there is one that keeps reappearing and I thought to write a short blog post so we can reference it in future discussions.


 


The question is- How do I undo someone else’s pending changes?


 


The scenario vary greatly but here are the top ones


·         I need to undo a pending change because I need to check-in and someone has it exclusively checked out


·         I just need to undo the checkout lock on the file and not the actual change itself


·         I need to undo all the changes in a workspace because the person has left the company or the group


 


Unfortunately, we do not support this from the GUI but you can achieve your goal from the command line. Assuming you are an administrator the command that you have to use is:


tf undo /workspace:OtherUserWorkspace;OtherUser  $/Project/ItemName.cs /s:http://yourtfsserver:8080


 


For the other scenarios I think I will borrow content from one of jmanning blog


(http://blogs.msdn.com/jmanning/archive/2006/01/26/518175.aspx )


1)      As an admin, you have the UnlockOther permission to all items in the version control repository.  This means that you can undo anyone else’s locks on any item.  The command-line for that would be something like: tf lock /lock:none $/whatever/item/goes/here/web.config. The lock command is covered @ http://msdn2.microsoft.com/library/47b0c7w9(en-US,VS.80).aspx

2) As admin, you also have the global version control permission AdminWorkspaces – this gives you the simpler and cleaner approach that you can just delete that user’s workspace (you don’t have to do it from his machine).  That will take with it any pending changes, any locks, etc. that the workspace was holding.  The command is just:  tf workspace /delete hisworkspace;DOMAIN\hisuser – the workspace command is covered at http://msdn2.microsoft.com/library/y901w7se(en-US,VS.80).aspx

Since the user has moved on to another company, team or project, deleting his workspace is likely the better answer. In addition, you do not have to manually undo that checkout lock (or worry about that user potentially having other locks held in that workspace).


-mario


Comments (6)

  1. Although its a task you seldom would want to do, it might become a necessity when someone leaves the

  2. Brian says:

    The days of the command line to do major tasks like this are long gone. Why not expose this on the UI? The difficult thing is that I can’t figure out what “Workspace” the user halfway across the planet has… This is a realistic use case that is missing from the TFS UI. It’s in every other source control vendor’s product. Poor design. I’ve wasted over an hour of my day to do soemthing that this expensive product should do out of the box. Frustrating.

  3. Sudheesh says:

    A neat little utility called the TFS SideKick was quite handy for us to do the same. And it has a GUI.

  4. Dale says:

    SideKick doesn’t help if you can’t delete the workspace.  In my case, the user is still in the company and still developing.  He no longer has a workspace pointing to the project with the locks and there is no copy in his PC.  Yet the locks are there and I can’t delete them.  Even VSS supported this.  How did MS miss this on 4 years worth of TFS so far from 2005 to now?  

  5. Dale says:

    So, if I may add, I have to use the tf lock to remove the lock including typing a long project file path since the $ path in source explorer cannot be highlighted and copied with Ctrl-C.