Force TFS Check-In / Undo in TFS 2012

Sometimes we could have some problems to access to a specific machine where we have some of our code checked out. Maybe the person who was programming those files left, or maybe for some reason we lost connection with that environment.
That’s when we have to force TFS to check-in the files, or if we couldn’t do it, at least force the undo… and do again the pending changes…
First, we have to open a new Visual Studio Developer Command Prompt. Then, we try to force the check-in:

tf lock /lock:none $/PROJECT/FOLDERS/FILE.cs /workspace:MYWORKSPACE;MYUSER

If we can’t force the check-in, we usually receive the message:

TF10152: The item XXXX must remain locked because its file type prevents multiple check-outs.

If we can’t force it, we’ve to do an Undo to revert the last changes (so we’ll lose everything that we’ve done):

tf undo $/PROJECT/FOLDERS/FILE.cs /workspace:MYWORKSPACE;MYUSER

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.