Does TFS branching have a child parent relation?

2019-02-20 02:01发布

问题:

When doing branches in tfs, does it matter if you are branching A to B or from B to A? The thing is that we have branch A and branch B, and now branch A has got messed up and we would like to recreate it from branch B by branching a new branch from B. As far as I know when you do a branch you get a relationship between the branches, but you don't get a "parent-child" relation, is that correct?

Is my question clear?

回答1:

At the point where a new branch is constructed, it gets equal to what you chosen to branch out from.
The tricky point about TFS-merging (as opposed, for example to the P4 intergration, or ClearCase merges) is that at any given point merging A-->B & B-->A will not generate the equal amount of merge candidates.

Let's say branch A generates branch B:

------->A
         \
          \
           -----> B

Let's say you make changes in A:

------->A-->A'
         \
          \
           -----> B

If you try to merge A' --> B you will get as merge candidates all your changesets/source files that were changed from A-->A'.
But if you try to merge B --> A' you will get no merge candidates at all.

This behavior is regardless of fact that A is 'parent'.

If your 'A' is messed and cannot be rectifed with regular merge from B-->A, you have the following options:

  • Destroy A and generate a fresh copy of B in a new branch C
  • Rollback changes from A, until it reaches 'stable'
  • Perform a baseless merge from B-->A and force B-state on A

(Possible slightly off-topic, but an excellent read nevertheless - and valuable for my grasping of the TFS-way: This article by R.Banks)