Question

In my TFS source control repository I have three branches laid out like this:

MAIN
 |
  -> DEV
      |
       -> TEST

I want to merge directly from TEST to MAIN without merging through the DEV branch.

MAIN .......
 |         .
  -> DEV   .
      |    V
       -> TEST

I'm unable to find an easy way to achieve this. Please help me find out whether this is possible.

Was it helpful?

Solution

This is possible but not recommended. This is what you'd call a baseless merge in TFS. Without installing any extensions to Visual Studio you can only perform this from the commandline.

Because TFS will not look up the common ancestor for the files being merged it will present every change as a conflict and will require you to manually merge each and every one of them. When merging through DEV TFS will be able to find the common parent and use that to do a 3-way merge.

Additionally, once TFS merges between two unrelated branches it will create a branch relationship between the two paths. Going forward it will show the path from TEST to MAIN as a valid merge direction.

There is an alternative to this in the form of a Shelfset Transplant. This basically shelves all the changed files and will allow you to apply the changed files to a different branch without creating a branch relationship.

If all of this doesn't deter you, then these are the ways to do it:

  • In the Merge window in Visual Studio enter the path you wish to merge to manually in the dropdown menu (VS2012 and up)
  • On the commandline use tf merge /baseless /recursive source target to create a new merge relationship.
  • Use the Visual Studio Power Tools' tfpt unshelve /migrate /source:<> /target:<> shelvesetname to unshelve changes from a shelveset created on one branch to another branch.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top