Is it possible overwrite a branch with another?
Or is the only solution to delete branch B and make a new branch from Branch A?
Is it possible overwrite a branch with another?
Or is the only solution to delete branch B and make a new branch from Branch A?
Unless you're running TFS 2010, I'd recommend using Merge + Resolve to bring the two branches back in sync.
# cancel out of conflict dialog
tf merge A B -r -force -version:T
tf resolve B -r -auto:acceptTheirs
That should equalize everything, except for files that were only created in B and never merged back. Use Folder Diff to find & reconcile them.
Delete + rebranch in 2005/2008 runs the risk of nightmarish-to-debug namespace conflicts in the future. The other option, if you have 2008, is to Destroy + rebranch. Obviously that assumes you are ok with losing all the history from the original copy of B.
In Visual Studio 2010, I just used the baseless merge to achieve this:
Tf merge /baseless [source path] [target path] /recursive
When the resolve conflicts window popup, select 'Take source version' option. Note, the files only exist in target will not be deleted by using baseless merge, but you can compare the 2 branches to identify the difference and delete them manually.
Refer to: http://msdn.microsoft.com/en-us/library/bb668976.aspx
I had success using Richard Berg's answer but felt like there were a few details that were missing. This is how I was able to eliminate differences related to conflict resolutions and changesets that had not been merged back to the source and make the target identical to the source. Note that this is how I will be referring to the branches - source is the one that should not be changed while target is the one that should be made identical to source.
tf merge $/target $/source /recursive /discard
Note: Make sure that you have set the working folder to a path within your workspace so that the tf tool knows which workspace and TFS server to use.
Check that there are differences between the branches that should be addressed - if not, no further action is required.
3.1. View history on the target branch and find the last complete merge from the source to the target (ignore any cherry picking merges as that will result in lots of false positives) - note the changeset number. An easier alternative would be to perform a merge from the source branch into the target branch to get the lastest version from the source branch into the target branch.
3.2. Right click on the source branch in the Source Control Explorer and select Compare from the context menu. Only take the latest version for the source if you merged the source branch into the target branch in step 2.1. Otherwise select Changeset from the Source Version | Type combo box and then enter the changeset number from step 2.1.
3.3. Use the drop down arrow on the Browse button next to the Target Path field to select Server Path. Then select the target branch in the dialog that opens.
3.4. Click OK on the Compare dialog to perform the comparison.
tf merge $/source $/target /recursive /force /version:T
Note: the T version specification indicates the latest version.
Close the merge conflicts dialog.
Automatically resolve all conflicts by choosing the source branch.
tf resolve $/target /recursive -auto:TakeTheirs
Check in.
Confirm that there are no longer any candidates for merges from the target to the source and that there are no differences between the two branches (this time just using the latest versions as we did a forced merge of the latest version in step 4.).
See MSDN for more details on the tf merge and resolve commands.
Delete the branch B and create a new one from branch A.
Is there a reason why you do not want to do this?