Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to branch and merge in TFS

Tags:

This question is a derivative of a previous question: How to version resources that are shared across projects

I have a project that contains code that is consumed by many other projects. Specifically, one folder in this parent project has been branched to dependent child projects.

We have since made changes in the parent project and checked them in. In Source Control Explorer, I right click on the branched folder in the parent project and select "Merge", intending to push the changes to a dependent project. I select the child project as a destination and then select "Latest Version". The wizard informs me "There are no changes to merge."

From my perspective, this isn't true, since the recently updated files are clearly different.

Is there a fundamental misunderstanding of the merge process in TFS here? What do I need to do differently?

like image 259
betitall Avatar asked Apr 23 '09 21:04

betitall


People also ask

How do I merge from one branch to another in TFS?

Choose Merge from Local to open the Source Control Merge Wizard: In the Source Control Merge Wizard, the Main branch is chosen automatically: Choose the latest version: Check Pending Changes/Included Changes.

How do I merge a branch to master TFS?

In order to merge branches, right click a database in the Object Explorer pane and from the More source control options sub-menu, select the Merge branches option: This initiates the Merge branches dialog: Browsing through a repository, source and target branches can be set.

How do I branch a project in TFS?

In Source Control Explorer, right-click the folder or file that you want to branch, point to Branching and Merging, and then click Branch. The Branch dialog box appears. In the Target box, modify the location and name for the new branch. You can also click Browse to specify a target.


2 Answers

The TFS merge engine relies almost entirely on history, not file contents. This makes it efficient for very large trees, and flexible for tasks like safely cherry-picking changes -- but it also makes answering your question difficult.

The first step is to understand the diagnostic commands tf history, tf merges, and tf merge /candidate. Here is a good introduction: http://blogs.msdn.com/dstfs/archive/2009/04/15/a-note-on-merging-and-the-use-of-tf-merges-tf-merge.aspx

If you are new to branching & merging in TFS then your history is probably not very complex. I think it's likely you'll find your answer with one quick call to tf merges. However, tracing merge history can become extremely convoluted in the general case, so if you have trouble feel free to post back with more details.

like image 66
Richard Berg Avatar answered Sep 24 '22 08:09

Richard Berg


Go to one specific file you know has changed in your "parent" project. Try merging just that file. Don't check anything in; just see what happens.

Something to watch for: The merge tools will not include files that have been added after you branch. You have to branch new files explicitly before you can merge any further changes. If a file is added to both parent and child folders without using a branch operation, the merge tools don't treat them as versions of the same file (and you can't merge changes between them).

like image 36
Robert Lewis Avatar answered Sep 23 '22 08:09

Robert Lewis