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