Search code examples
c#visual-studiotfsbranching-and-mergingsource-control-explorer

TFS Branching - 2 Development branches


I currently use TFS and have the following structure.

A Dev line, a Mainline and a Release line in my TFS hierarchy. I use the same approach as detailed in the below link :

http://blog.tfsserver.com/a-straightforward-guide-to-branching/

(I plan on keep 2 or 3 most recent releases in the release line)

The mainline is the most recent version of code and a new release folder will be created to keep when the mainline code is tested and approved.

Currently in my dev line I have a dev branch which was created from the mainline.

This exsiting dev branch is currently being worked on by a developer where the changes will be ready in 4 weeks lets say.

I currently need to make urgent changes to the current version of code in production (Mainline) and I know these changes will take me 2 weeks to complete and test.

With this in mind, I obviously dont want to use the existing dev branch.

I cant make changes directly on the mainline so I am wondering if the following approach I am condsidering is the correct approach?

I am thinking I need to :

(1) Create a NEW Dev branch from the mainline. I would then have my original/existing dev branch and now a NEW dev branch. Both would be branched therefor from the same original code.

(2) Make my changes in the NEW dev branch

(3) Once I am happy with my changes, I would then merge my changes with the Mainline and release the changes to production ( or selected customers) and merge my changes with the original Dev branch. Then, when the original dev branch changes are completed 2 weeks after mine, it would be merged with the mainline.

I am wondering is this the correct approach? Can I merge changes from the NEW branch to the existing dev branch even if I didnt create my new branch from the existing/original dev branch?

Thanks


Solution

  • If you branch from the release branch, you can merge those changes back, regardless of any other branches. They too can merge their changes, but they may have to go through a merge conflict resolution step if you have both worked on the same file.

    When you merge your changes into the Mainline, then the dev branch can merge the changes down from Mainline into their code.

    Another option, if you don't want to check in changes to mainline yet... if you're using a recent version of Visual Studio and TFS, then you can use shelvesets to merge code between branches. However, only recent versions of VS/TFS do Shelveset merges on Unshelving. Previously, it just copied whatever version of the file was shelved over any changes you might have made.