<p>Is it possible to merge to a branch that is not a direct parent or child in TFS?  I suspect that the answer is no as this is what I've experienced while using it.  However, it seems that at certain times it would be really useful when there are different features being worked on that may have different approval cycles (ie. feature one <strong>might</strong> be approved before feature two).  This becomes exceedingly difficult when we have production branches where we have to merge some feature into a previous branch so we can release before the next full version.</p>

<p>Our current branching strategy is to develop in the trunk (or mainline as we call it), and create a branch to stabilize and release to production.  This branch can then be used to create hotfixes and other things while mainline can diverge for upcoming features.</p>

<p>What techniques can be used otherwise to mitigate a scenario such as the one(s) described above?</p>

[{'answer_id': 52841, 'author': 'Ben Scheirman', 'author_id': 3381, 'author_profile': 'https://Stackoverflow.com/users/3381', 'pm_score': 1, 'selected': False, 'text': '<p>AFAIK you can do this as long as the branches were created off of the same original folder.</p>\n\n<ul>\n<li>trunk/</li>\n<li>branches/\n-/feature1 (branched from trunk)\n-/feature2 (branched from trunk)</li>\n</ul>\n\n<p>If you do this then you should be able to merge between feature1 and feature2 as well.</p>\n\n<p>Though my branching/merging experience with TFS leaves me wanting more.  I wish we just had SVN.</p>\n'}, {'answer_id': 52853, 'author': 'Harpreet', 'author_id': 855, 'author_profile': 'https://Stackoverflow.com/users/855', 'pm_score': 2, 'selected': False, 'text': "<p>You may want to revisit your branching strategy.  How do you get production branches?  Are you merging all code from development branches, regression testing and then creating a production branch for fixes?  Or are you developing on the trunk and then creating production branches to stabilize and release from?  The second way creates problems of the type you're describing.  If you are using the first approach -- the trunk is supposed to be only for things that have been built on branches tested and then merged you will run into this much less often.  Under that approach if you're still having this problem it may be because your development effort is very large and you may need a relatively complex branching strategy with layers of branching and promotion.</p>\n"}, {'answer_id': 52894, 'author': 'Mark Cidade', 'author_id': 1659, 'author_profile': 'https://Stackoverflow.com/users/1659', 'pm_score': 3, 'selected': False, 'text': '<pre><code>tf.exe merge /recursive /baseless $/TeamProject/SourceBranch $/TeamProject/TargetBranch\n</code></pre>\n\n<ul>\n<li>MSDN: <a href="http://msdn.microsoft.com/en-us/library/bb668976.aspx" rel="noreferrer">How To: Perform a Baseless Merge in Visual Studio Team Foundation Server</a></li>\n</ul>\n'}, {'answer_id': 52895, 'author': 'Dan Shield', 'author_id': 4633, 'author_profile': 'https://Stackoverflow.com/users/4633', 'pm_score': 1, 'selected': False, 'text': '<p>Yes, you can do a baseless merge, but only from the command line (tf.exe).</p>\n'}, {'answer_id': 52907, 'author': 'Brian Stewart', 'author_id': 3114, 'author_profile': 'https://Stackoverflow.com/users/3114', 'pm_score': 1, 'selected': False, 'text': '<p>TFS will allow you to merge with a branch that is not a parent/child - these are called baseless merges. See these links:</p>\n\n<p><a href="http://msdn.microsoft.com/en-us/library/bb668976.aspx" rel="nofollow noreferrer">From MSDN</a></p>\n\n<p><a href="http://www.codeplex.com/VSTSGuidance/Wiki/View.aspx?title=How%20To%3A%20Perform%20a%20Baseless%20Merge%20in%20Team%20Foundation%20Server&amp;referringTitle=View%20More" rel="nofollow noreferrer">From the TFS Team via CodePlex</a></p>\n\n<p>We typically do major or destabilizing changes on a development branch. If close to a major release of one of our products nearly all changes will be done on a branch.</p>\n'}, {'answer_id': 52909, 'author': 'Justin Dearing', 'author_id': 3110, 'author_profile': 'https://Stackoverflow.com/users/3110', 'pm_score': 5, 'selected': True, 'text': '<p>I agree with Harpreet that you may want to revisit how you you have setup you branching structure.  However you if you really want to perform this type of merge you can through something called a baseless merge.  It runs from the tfs command prompt, </p>\n\n<pre><code>Tf merge /baseless &lt;&lt;source path&gt;&gt; &lt;&lt;target path&gt;&gt; /recursive\n</code></pre>\n\n<p>Additional info about baseless merges can be found <a href="http://www.codeplex.com/VSTSGuidance/Wiki/View.aspx?title=How%20To%3A%20Perform%20a%20Baseless%20Merge%20in%20Team%20Foundation%20Server&amp;referringTitle=View%20More" rel="noreferrer">here</a></p>\n\n<p>Also I found this document to be invaluable when constructing our tfs branching structure\n<a href="http://vsarbranchingguide.codeplex.com/" rel="noreferrer">Microsoft Team Foundation Server Branching Guidance </a></p>\n'}, {'answer_id': 56397578, 'author': 'Iannazzi', 'author_id': 1303144, 'author_profile': 'https://Stackoverflow.com/users/1303144', 'pm_score': 0, 'selected': False, 'text': '<p>I am far from a TFS expert, but I think you can merge siblings, and I think it is not a baseless merge. </p>\n\n<p>We branched off our main branch (branch name "main") for a feature (branch name "feature"), then I needed some of the work in a branch that was also branched off the main branch (branch name "dev"). I would consider feature and dev branches to be siblings as they both came from the same parent. I merged feature to dev and all files (14000) were marked as merge, some were marked as merge,edit. I could not cancel (visual studio would just hang), so I accepted the merge. Then I merged dev to main, then I pulled main to feature, and again 14000 files were marked for merge. I was really upset, and afraid this would continue.</p>\n\n<p>At this point we did a test project. We set up main, then branched dev and feature from main. We repeated the above steps with the same results. Once we completed the merge from main to feature, all future merges only showed the edited files.</p>\n\n<p>After our little test I completed the merge from main to feature. And just like the test our merges now only show the edited files. We can go dev to feature, feature to main, main to dev, etc. </p>\n\n<p>I did notice when branching all file dates were modified. Maybe this is an issue?</p>\n'}]
['https://Stackoverflow.com/questions/52824', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/5416/']