This is a big issue in Team Foundation Server (TFS), how to get rid of this? Sometime users(system crash, different domain, or users that are not in Active directoy) forget to CheckIn files that were cehecked out by them exclusively.
The only solution to this problem is to restore the version that was Checked In at the last. and for doing that we need to remove/delete the workspace in which the file was checked out.
Following are the steps for deletion of a workspace:
- Go to Visual studio command prompt and type “tf workspaces”. This will show all the workspaces on that server. (you can also check workspaces by server, owner etc.)
- If the user is present in Active Directory then execute the following command: tf workspace /delete /server:http://tfs-server:8080 “Nauman-WorkSpace;Nauman”
- this will remove the Workspace named: Nauman-WorkSpace, that is owner by user:Nauman on Server: http://tfs-server:8080
If user is not present in Active Directory that we need to take another route because above method will return an error: TF50605: There was an error looking up the SID for Nauman.
At this point, we need to open up the TfsVersionControl table and manually point the workspaces to a valid identity. The first stage is to identify the ID of the missing account:
SELECT IdentityId FROM tfsVersionControl.tbl_Identity WHERE (DisplayName LIKE ‘Nauman’
Now that we have the ID, we can locate the workspaces the owner has on the server we’re having problems with.
SELECT WorkspaceId, OwnerId, WorkspaceName FROM tfsVersionControl.tbl_WorkspaceWHERE (OwnerId = 58) AND (Computer = 'Server1')
Now you should update the tfsVersionControl.tbl_Workspace table with a valid IdentityId from the tfsVersionControl.tbl_Identity table
Once updated use the following command again with the updated identity user and now it will work: tf workspace /delete /server:http://tfs-server:8080 “Nauman-WorkSpace;Nauman”
Now previous version of file is available for checking in/out.