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.

In this article, I will be using TF Command-Line Utility Commands that are also available for cloud based TFS. This makes sense and is very handy to resolve ghost pending changes.

 

Pre-requisites

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.

Pending Changes on Visual Studio 2010

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>

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>

tf undo

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.

05. Get Latest Version Recursively

Source Control Explorer will show the latest check outs. If it had check outs by another team member, it will show as follows:

 Source Control Explorer with other user's pending changes

 If there is no check out by other users, it will look similar to the following:

Source Control Explorer - After Undo Campaign Management

 

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.

 

Wrap Up

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.

 

Further Reading

TF Command-Line Utility Commands

Team Foundation Service – a cloud powered source control management by Microsoft

 

 

Categories:

3 Responses

  1. This was JUST the thing I was looking for. Your experience is exactly what I’ve just gone thru ( including the laptop brand, model and SSD problem. )

    I’m so thankful that you took the time post all of this. Its been an absolute lifesaver!! 🙂

    Best regards

  2. Thank you so much for this article, I’ve been trying to undo phantom TFS change for days without success!

    What happened to me was a bit different scenario: I did a merge, the merge went totally wrong, so I decided to do a rollback. I did undo all, but the one pending change remained, and the pending change was a total mess, merge operation instead of creating a folder and a file inside the folder, just created a file whose name was name of the folder and name of the file together. And I couldn’t do anything with this ghost pending change, nor checking nor undo. That was until I came across your solution 🙂

    Thanks a lot again!!!

    P.S. English is not my native language, sorry for any mistakes/typos.

Leave a Reply

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

Some simple Math is good for your brain! Thanks, Ms SQL Girl. * Time limit is exhausted. Please reload the CAPTCHA.

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