官术网_书友最值得收藏!

Performing a baseless merge between sibling branches in TFVC

Managing source code can get challenging when multiple Teams are contributing to the same repository. Are you already familiar with the branching and merging tools available in TFS? If not, I would encourage you to go through the ALM Rangers Version Control Guidance http://bit.ly/1He8pmL. The guidance talks in detail about the various branching strategy and its pros and cons.

An extract from the ALM Rangers Version Control Guide showing different branching strategies

Branching in TFVC can get complicated over time; branching in Git is lightweight and path independent. In Git, many developers create a branch for each new feature they are coding, sometimes on a daily basis. Git allows you to quickly switch from one branch to another to pivot among different variations of your codebase. When using Git, you can create branches that exist only on your Dev machine and share them if and when you're ready. Consider evaluating your source control requirements against the workflow at http://bit.ly/1P7UMvO; you may find Git a better fit.

In this recipe, you will learn how to carry out a merge operation between two unrelated TFVC branches often referred to as sibling branches.

Getting ready

In your TFVC-based Team Project, create a branching structure as illustrated in the following diagram. You can use the TFS Community Branch Tool extension to automate the creation of the branch, as illustrated in the following diagram (http://bit.ly/1LZR2bx):

We'll be working through the following scenario in this recipe. The developer working on Dev branch has found a critical issue that he has resolved with a code check-in. The QA branch is already being used by another developer to carry out some unrelated work. To get the fix from Dev branch into production, the developer decides to perform a baseless merge between the Dev and Prod branch.

In order to perform a merge operation, your user account needs to have the merge permission. The project administrator group already grants this permission; however, this permission can be set to Allow directly on individual users and groups:

How to do it…

  1. In Visual Studio, open Team Explorer, and navigate to the Source Control Explore. Perform a Get Latest Version operation on the FabrikamTFVC Team Project:
  2. To simulate a fix being made in the Dev branch, open the $\Dev\FabrikamFiber.CallCenter\FabrikamFiber.Web\Controllers\HomeController.cs file and copy the following comment in the Index method:

    Check in the code changes to this file from the pending changes view in Team Explorer:

  3. Now that the critical change is in the Dev branch, let's look at the steps required to carry out the baseless merge of this change from the Dev branch to the Prod branch. From the source control explorer, right-click on the Dev branch and choose Merge... from under the Branching and Merging submenu:
  4. The Merge wizard will not show the Prod branch in the Target branch dropdown. Unrelated branches can only be selected using the Browse... button. Click on Browse... and select Prod branch. Then, click on OK:
  5. A warning sign shows up next to Target branch indicating that the chosen branch is unrelated and will cause a baseless merge:
  6. Click on Next to navigate to the next screen:

    Note

    If the selection is changed from All changes to Selected changesets then a merge relationship between the two branches has not been established. While you would still be able to merge the change, you won't be able to visualize it.

  7. Keep the Latest Version selected in the dropdown and click on Next:
  8. Once the merge operation has completed, you'll be navigated to the Resolve Conflicts window. Click on Merge Changes In Merge Tool, then check and click on Accept Merge:
  9. The Resolve Conflicts window will clear of any conflicts once the merge has completed. From the pending changes viewed in Team Explorer, check in the pending changes:
  10. From the Source Control Explorer, right-click on the Prod branch and choose View History. Check all the branches and click on Visualize. The dashed line from Dev to Prod represents the baseless merge.

How it works…

When a baseless merge is carried out, a relationship is established between the two sibling branches. The baseless merge is represented by the dashed line:

To get a view of the timeline of the change, hit the Timeline Tracking view at the top of the screen:

主站蜘蛛池模板: 福泉市| 柘荣县| 河西区| 哈尔滨市| 阳原县| 襄城县| 华宁县| 交城县| 潮安县| 琼中| 普宁市| 苗栗县| 长岭县| 昆明市| 威信县| 额敏县| 怀来县| 龙川县| 长沙市| 珠海市| 石阡县| 会理县| 惠州市| 凤冈县| 长葛市| 龙游县| 天镇县| 房山区| 定结县| 夹江县| 高唐县| 纳雍县| 芦山县| 象山县| 无棣县| 莱州市| 若羌县| 阳西县| 库尔勒市| 云阳县| 无极县|