-->

How to fix TFS incorrect branching

2019-04-01 04:25发布

问题:

We have a project that is in TFS 2010 and was incorrectly branched. We want to fix it. This is the current structure we have:

  • Development
  • Integration
  • Main

The problem is that Main is a branch of Integration, which in turn is branch of Development, when it should be the very opposite.

In other words, first it was created Development, then branched Integration and then Main.

Now all three branches have same code (were merged).

So, Is it possible to fix the TFS references to have the right flow: Main -> Integration -> Development?

回答1:

As far as I know, there is no way to make this change behind the scenes. The problem you have in hand is that the Development and Main branches are out of place. Easiest thing to fix this would be to rename the "Development" branch as "Main" and vice-versa or Use the REPARENT option as shown at the end of the answer.

Am assuming that in your case since you have only one DEV branch (it wouldnt be possible to have more than 1 dev with the current branching structure), the development for the next release wont happen till the current release is out in production right? In that case, you can wait till the end of the current release and then rename the branches, so that all the 3 branches are in sync before the rename.

(Keep in mind that "Rename" changeset would affect all the files and folders in your branch, and from the comments below I can understand that it can be very problematic if you do it at the wrong time. Choose your time very wisely, make sure that you dont have any changes pending between the branches and it's just the "Rename" changeset thats pending between branches)

Another approach would be to use REPARENT. After a great discussion in the comments below, I tried the options myself and the best way to fix this would be to use the "Reparent" option. I tried this out myself by creating three different branches. You can do the following to fix it:

  1. In Visual Studio, Click on the Main branch -> then File -> Source Control -> Branching and Merging -> Reparent. Select "No Parent" and then click "Reparent"

  2. Click on the INT branch -> then File -> Source Control -> Branching and Merging -> Reparent. Select "Main" and then click "Reparent".

  3. Click on the DEV branch -> then File -> Source Control -> Branching and Merging -> Reparent. Select "INT" and then click "Reparent".