Sep 15, 2010

How To Fix Branches After Migration to TFS2010

Let’s say you’ve just migrated your code from another version control system to TFS2010 by grabbing the old code, copying it into your workspace as is, and then checking it in to TFS as a single massive import.  It’s a really easy and common way to do tip migration.

When you do this, you will notice that all your branch relationships are missing and source control will look something like this:


The old system had Trunk branched to Feature X and Version 1, etc, but now there’s no relationships and trying to merge from Trunk to a branch brings up a dialog with no targets.


Bummer, huh?  Yeah, but what did you expect would happen? You’ve just imported a bunch of folders from the file system and TFS has no way of knowing that they’re branches.

We need to let it know which folders the branches are and the relationships between them.  Here’s how we do it:

Step 1: Convert Folders to Branches

Right click the trunk folder (or whatever your root branch folder is) and convert it to a branch.


It should now look like this:


Do this for all the other target branches you have.  e.g. Feature X and Version 1.

Step 2: Perform a Baseless Merge

Next, perform a TFS baseless merge to establish a relationship between the parent branch and the child branches.  Don’t worry about the contents, we’re only going to merge the folder, not it’s contents.

TFS baseless merges are performed via the command line, so open up your VS2010 command prompt and do the following:

cd <workspaceFolder>
tf merge /baseless <trunk> <childBranch>

Check in your pending changes.

Step 3 Reparent Child Branches

At this point we have a loose link between the branches but the relationships are still not finalised.  We need to fix that.

Select your child branch in Source Control Explorer and from the File menu choose Source Control –> Branching and Merging –> Reparent...  NOTE: This is not available via the context menu in Source Control Explorer.


In the dialog box, choose the appropriate branch as the new parent.  There generally should only be one, unless you have done multiple baseless merges.


Now look at the properties of your child branch and you should see something like this:


Excellent!  If you go to your Trunk branch and in the branch context menu choose View Hierarchy. You should see something like this:


Brilliant.  Now we’re all done.  You can carry on using TFS as you normally would.



  1. Love this post - will definitely find a use. (although my new work is SVN only... for now)

  2. You write: "Select your child branch in Source Control Explorer and from the File menu choose Source Control –> Branching and Merging –> Reparent... NOTE: This is not available via the context menu in Source Control Explorer." And then you have an image of a context menu. Very confusing

  3. @Anonymous That's not a context menu screenshot, it's a screenshot of the relevant part of the File menu :-)

  4. Hi Richard,

    We recently migrated VSS with full history directly to TFS (and we have a Trunk, Release1, Release2... folders).

    Is it possible to use this technique if files in both (former) branches have history?


  5. Hi Richard

    Hope you're well!

    Great and wonderfully articulated post!

    I was missing the 'baseless merge' step which allows me to reparent.

    Thanks heaps.

    Paul Sorauer

  6. Hi,

    Thanks to your excellent post I managed to recreate all the source code branches after moving our source code to a new TFS server!


  7. This is part of the answer, but I'm having some other serious issues...

    For example, if I select the branch and then select "Merge", the new relationship shows up fine.

    But if I select anything under that (a file, a folder, anything), the relationship is NOT present.

    Shouldn't it be? What point is a branch/merge relationship that doesn't apply to the children as well? How do I get it to? Do I have to do this process for every folder under the branch? That doesn't seem right (I shouldn't have to make EVERY folder into a branch!)

    Any help?

  8. Thank you! Exactly what I needed.

  9. Really nice article, helped me a lot!