TFS Source Control – Merging between Team Projects


To do a merge between 2 different Team Projects in TFS, you first need to establish the branch relationship. This cannot be done from the UI in VS 2008 and needs to be accomplished using the tf.exe command line tool. The branch relationship will be establish during the first merge operation which is a “baseless merge”. Subsequent merges do not have to be baseless. However, Visual Studio 2008 cannot read branch relationships established through baseless merge (by design) so all subsequent merges have to be done using the command line too.

Below is an example on merging the Main\Source folder from a Project1 Team Project to a Project2 Team Project.

Initial “Baseless” Merge

1. Get the latest version of both branches that need to be merged
2. Open Visual Studio 2008 Command Prompt

  • The shortcut should be in Start > Programs > Microsoft Visual Studio 2008 > Visual Studio Tools
  • If you can’t find it, just open a regular command prompt and go to C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE

3. Type the following command:

tf merge /baseless -r “$/Project2/Main/Source” “$/Project1/Main/Source”
  • tf is the TFS command line tool
  • /baseless is what prompts the tool to do a baseless merge (makes sense, huh?)
  • -r is to do a recursive merge so all sub-folders and files get merged
  • First string in quotes is the path to the source folder in TFS
  • Second string in quotes is the path to the destination folder in TFS

4. Resolve any conflicts as you normally would
5. Check-in your changes

Note: The initial baseless merge will merge all files even if they are identical between the 2 branches.

Subsequent Merges

1. Get the latest version of both branches that need to be merged
2. Open Visual Studio 2008 Command Prompt
3. Type the following command:

tf merge -r “$/Project2/Main/Source” “$/Project1/Main/Source”

4. Resolve any conflicts as you normally would
5. Check-in your changes

Note: This will only merge files that have changed in the source branch since the last merge operation

Advertisements

One Response to TFS Source Control – Merging between Team Projects

  1. Ronald Widha says:

    This is just what I needed. I’m trying to move one tfs project from one server to another. but the project contain 2 branches.

    with this, I can check the 2 branches independently and establish a merge relationship between them
    again. awesome. hopefully it works

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: