I have been using the Team Foundation Service (http://tfs.visualstudio.com) in the last 7 months for a couple of my projects. Recently I have had to change laptops twice due to SSD issues on Lenovo T420s. So, I am on a third laptop (aouch!). One of the challenges that I had to go through when migrating from one (crashed) laptop to another is resolving Pending Changes associated to my account workspace on the crashed laptop. Despite my best efforts to check-in my work fairly frequently, disaster was inevitable and I still had ghost pending changes.
I call pending changes associated to my workspace in crashed laptop as “ghost pending changes”.
Once I have my new laptop setup, and Team Explorer installed on Visual Studio 2010, I am ready to investigate what the ghost pending changes are from my crashed laptop, recover the files from the crashed laptop, remove the ghost pending changes and check-in the files recovered via the new laptop.
Install Visual Studio 2010 and Team Explorer in the new machine.
On the new machine, connect your Visual Studio to the existing team project on cloud TFS. This will create a new workspace in the new machine.
5 Steps to Recover Ghost Pending Changes
Below are some quick tips to tidy up loose ends from a workspace (e.g. a crashed laptop) with Pending Changes.
1. Backup the changes you have made from the crashed laptop, if possible.
If your hard drive / SSD is still salvageable and you can retrieve local copy of your TFS folder(s), make a copy of them in another hard drive and store them some where. Pronto! Don’t delay it.
2. Find out ghost pending changes and investigate the severity of potentially lost work.
In Source Control Explorer within Visual Studio, you can check folder by folder to see the changes that are not checked in by all users. Although this can be cumbersome if you have multiple collections and folders.
Fortunately, there is a handy command that you can use.
tf status /user:<your user name> /recursive > <output file path>
More documentation on the Status command: http://msdn.microsoft.com/en-US/library/9s5ae285(v=vs.100).aspx
3. Get the workspace name
Before undoing the pending changes, you will need to know the name of the workspace that you are trying to undo. In my case, I have three workspaces, one for each laptop where I have installed TFS. The first one from my first crashed laptop. The second one from the latest crashed laptop. So, I want to undo the one from the latter one.
Using the following command, I can find out the list of workspaces related to my user name.
tf workspaces /owner:<user name>
In this example, the one that I want to “undo” the pending changes is “JKOESMARNO-T420”.
More documentation on Workspaces command: http://msdn.microsoft.com/en-us/library/54dkh0y3(v=vs.100).aspx
4. Undo the pending changes.
Now that we understand the severity of the files with ghost pending changes, we can undo the pending changes. Use the following command to undo one collection at a time:
tf undo /workspace:<Workspace Name> /recrusive <Collection Name>
More information on the Undo command: http://msdn.microsoft.com/en-us/library/c72skhw4(v=vs.100).aspx
Once you undo pending changes, make sure you perform “Get Latest Version (Recursive)” on each Collection via in Source Control Explorer.
Source Control Explorer will show the latest check outs. If it had check outs by another team member, it will show as follows:
If there is no check out by other users, it will look similar to the following:
5. Re-do the changes and check them in.
If you are lucky and manage to salvage the local changes from the crashed laptop that are not checked in, it may be a good idea to copy them to the new system and check them in.
6. (Optional) Remove unwanted old workspaces
Use the following command to delete unwanted old workspaces. You could substitute Step 4 above with this step.
tf workspace /delete:<Workspace Name>
Note: If you delete a workspace that contains pending changes, Team Foundation cancels the pending changes as part of the delete process. Deleting a workspace does not delete the files and folders on the client computer that were in that workspace.
TF Command-Line Utility Commands are powerful and work with Team Foundation Service (a cloud based version control from Microsoft). Using TF commands, we can resolve ghost pending changes before continuing development in a new environment.
Team Foundation Service – a cloud powered source control management by Microsoft