Thursday, 18 April 2013

How to branch/merge with TFS 2010


Below is a simple explanation of TFS branching and merging for one branch and one merge.

Branching
  1. Make sure you have all files check in or shelved
  2. Open Visual Studio 2010 Team Explorer panel
  3. Open your project > Source Control
  4. Make sure your folder structure is like this:
    1. BuildProcessTemplates
    2. Main
      1. All your project source code
  5. If your source code is not in this folder structure above then:
    1. Create a Main folder
    2. Right-click individually on each folder/file and select Move and choose Main as the destination (Can’t multi-select and move for some reason)
    3. Your history will be kept
  6. Check in all your changes
  7. Now right-click on the Main folder and select Branching and Merging > Branch
  8. Now in Target Branch Name type the name of your branch e.g. FeatureBranch1
  9. Click OK (keep default checkbox selections)
  10. Wait until branching has completed and then check in all changes


You will now have a Main branch  e.g. C:\Dev\Project\Main, and a FeatureBranch1 branch e.g. C:\Dev\Project\FeatureBranch1. So open the FeatureBranch1 solution and make all your branch changes there. Then when you ready  you can merge this branch into Main.

As I rule we should label our check-ins for:
  1. The main like this Project: Then the check in description e.g. Puma: Fixed menu layout
  2. The branch like this Project\FeatureBranch1: Then the check in description e.g. Puma\FeatureBranch1: New regions implemented

Merging
  1. Make sure you have all files check in or shelved
  2. Open Visual Studio 2010 Team Explorer panel
  3. Open your project > Source Control
  4. Get latest on the Main branch
  5. Now right-click on the branch folder e.g. FeatureBranch1 and select Branching and Merging > Merge
  6. Source branch should be FeatureBranch1 and Target branch should be Main – Click Next
  7. Version type should be Latest Version – Click Next
  8. Click Finished
  9. The merge will now occur and bring up any conflicts - Resolve the conflicts (easier said than done)
  10. Check in the merge when you confident it works


Shane


No comments: