- Microsoft Team Foundation Server 2015 Cookbook
- Tarun Arora
- 511字
- 2021-07-16 09:41:17
Reparenting a branch in TFVC
Team Foundation Version Control provides you with an option to prune a branch from somewhere in a given hierarchy and graft it on elsewhere in the same hierarchy. Consider using this approach if the branch structure you put in place is incorrectly set up or has stopped working as you have scaled up. In this recipe, you'll learn how to reparent a branch in TFVC.
Note
The movement of the reparented branch is logical not physical and can be done without stopping developers from working. However, it's a good idea to get developers to shelve changes. You should also endeavor to make the new parent as close in content to the old parent to avoid merge conflicts.
Getting ready
In order to reparent a branch, your user account needs to have the Manage branch permission. The project administrator group and project collection administrator group already grant this permission; however, this permission can be set to allow directly on individual users and groups:

The Manage branch permission allows you to perform the following:
- Convert a folder into a branch
- Execute the following actions
- Edit the branch properties
- Reparent the branch
- Convert the branch into a folder
In your TFVC project, create a branching structure as illustrated in the figure on the left:

The scenario we'll be working through in this recipe, as illustrated in the figure on the left, is the Development Team releases from the Main branch; Release 1.1 was branched from Release 1. As illustrated in the figure on the right, the Team wants to move Release 1.1 directly under the Main branch, so changes don't need to go through Release 1 to be merged to Release 1.1.
To reparent the branch Release 1.1 from Release 1 to Main, a relationship needs to be established between the two branches. This can only be done by performing a baseless merge between the two branches. Refer to the Performing a baseless merge between sibling branches in TFVC recipe to learn how to perform a baseless merge.

This recipe assumes that a merge relationship has been established between the Main and Release 1.1 branch. In the preceding figure, the dashed line represents a relationship between the two branches.
How to do it…
- Navigate to Source Control Explorer, right-click on the branch Release 1.1 and choose Reparent... from the Branching and Merging submenu:
- In the Reparent window, you'll see a list of all branches that have a direct or indirect relationship with Release 1.1. Select Main and click on Reparent. Selecting No parent will make Release 1.1 an independent branch:
- The reparent operation takes place on the server. You will not see any pending changes as a result of the reparent operation. The branch hierarchy after the reparent operation is as follows:
How it works…
Once the reparent operation has been completed, you can view the updated branch hierarchy by right-clicking on the Release1.1 branch and choosing Properties from under the Advanced submenu:

Click on the Relationships tab from the left menu to see the branch relationships.
- 深入淺出Java虛擬機:JVM原理與實戰(zhàn)
- 跟小海龜學Python
- Learning ELK Stack
- ArcGIS By Example
- 單片機應用與調試項目教程(C語言版)
- Learning JavaScript Data Structures and Algorithms
- Android Wear Projects
- Access 2010中文版項目教程
- Django 3.0入門與實踐
- HTML5開發(fā)精要與實例詳解
- Managing Microsoft Hybrid Clouds
- Java 9 Programming By Example
- 區(qū)塊鏈架構之美:從比特幣、以太坊、超級賬本看區(qū)塊鏈架構設計
- Oracle 12c從入門到精通(視頻教學超值版)
- 從零開始:C語言快速入門教程