TFS - Make 2 Existing Folders related branches - tfs

I am working with TFS 2012 and wondering if I can accomplish something easily. I have two folders with several sub folders ... in a previous SC they were branches of each other.
Is there a way in TFS to make them have a "relationship"? I've used the "Convert to Branch" on both. When I try to "Merge", not surprisingly it has an "!" mark and says "A merge relationship does not exist between the source and the target. A baseless merge will be performed."
So is there any way to "create" that relationship? I realize I could delete one of the folders in TFS, create the branch, and then copy all the original files into the branch location and then check them in. But outside of that is there a way? I tried "Reparent" but the pick list is empty.

The trick is to go to the commandline where you can perform a baseless merge using:
Tf vc merge $/proj/branch1 $/proj/branch2 /baseless /recursive
After which you can use the reparent feature to setup the correct parent/child relation.
See also
https://alistairbmackay.wordpress.com/2014/01/15/tfs-reparenting-a-branch/

Related

Microsoft TFS 2010 - Branching and Merging

I need to branch and merge hundreds of files and the only way I know is to do it manually one by one.
Is there an automated way where I can just list all the file names with their path, add change set, and indicate the destination for it all to run by itself or better yet since the files have similar names (project id), an condition where it should go.
You can branch and merge at the folder level. You do not need to branch and merge individual files, you can branch and merge a folder that contains all of the required files.

TFS merging from sub-child to main direclty

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.
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.

TFS baseless merge

I am merging two branches which do not have a parent child relationship. I have started with a single file to test if the merge is working properly before the actual merge. I am using tfs baseless merge in order to do this.The following is the command:
Tf merge /baseless C:\Inetpub\wwwroot\Test\CreateDescription.aspx.cs C:\Inetpub\wwwroot\Test1\CreateDescription.aspx.cs /recursive
Changes have been done in both the files. However in the resolve conflict dialog box I only see two options
1) Keep the changes in the target branch
2) copy code from source branch
Merge changes in merge tool is greyed out. What should I do in order to enable this option. I want to manually merge changes in the both the branches.
A simple way to do this would be to check out the file you want to be the target (i.e C:\Inetpub\wwwroot\Test1\CreateDescription.aspx.cs) and then use an external merge tool to merge the changes. I'm a big fan our SourceGear Diffmerge, mainly because it's free (as in beer). This will allow you to merge the files and resolve the conflics.
Once you've done this, you could run the baseless merge to establish the merge relationship between the branches and tell the merge tool in TFS to keep the changes in the target. You can also tell TFS to use DiffMerge as it's merge tool which might get rid of the problem all together.

Converting folder copies to branches in TFS 2010

TFS 2010 introduced the ability to convert basic folders into branches. The documentation also speaks of "reparenting a branch" (which does not appear in source control explorer context menu but is accessible only through File>Source Control> Branching & Merging ... hard to find ...)
Let's say I have folders A and A2 under source control.
A2 was COPIED from A some time ago, but is not a branch of A. It is just copied, added to source control and checked-in. Since they are not declared as branches, there is no history of merge operations between A and A2.
The commands "Convert to branch" and "Reparent branch" make me think that both A and A2 can be converted from basic folders to branches and A can be configured as the parent branch of A2, thus giving me the ability to use all the juicy branch features of TFS 2010.
I couldn't get this done. I converted both A and A2 to branches but there are no relations between them. While trying to "reparent" A2, I can not selected A as a parent branch.
How can I do this? If what I am trying to do is not possible, then what is "Convert to branch" and "Reparent Branch" good for?
Reading from different sources you should be able to use Convert to Branch and Reparent Branch after doing a baseless merge between the folders.
Do a baseless merge, but do not actually change any files:
tf merge /baseless /recursive /discard <source> <destination>
Update for VS2012 users:
Visual Studio 2012 does Baseless Merges, which can save time (no TF command line needed)!
I came across this when wanting to branch Master to a specific existing BugFixes folder, which I had converted into a branch.
Simply merge the two unrelated branches, Check In and then reparent.
Works like a whiz! This is what the baseless merge in VS2012 looks like. Thank you to Sahas Subramanian .
http://www.incyclesoftware.com/2012/08/baseless-merge-vs-2012-ui/
See http://www.incyclesoftware.com/2012/08/baseless-merge-vs-2012-ui/ for a walk through (
thanks for the image).
I've never done this before, but here is the link in msdn describing how to do this: http://msdn.microsoft.com/en-us/library/ms181425.aspx

How do I merge a Work Item from 1 branch to another in TFS 2008

I can't seem to find an easy way of doing this.
We have a trunk, which has a particular set of Changesets checked into a Work Item in TFS. I want to exclusively merge the changesets in this Work Item into another branch.
Surely this can't be difficult?
TFS absolutely does support cherry-picking. However, the range of changesets you cherry-pick must be contiguous. If you need to merge a set of changesets that has "gaps" in it, you'll need to run Merge multiple times. If the merge operations end up touching the same files, you will probably need to Checkin between merges.
You should be able to do this in a normal merge by simply selecting the changesets you want.
Open Source Control Explorer window in VS
Right click on the trunk (the folder that the original branch was made from)
Select Merge
Select the target branch to merge to from the dropdown list (if it doesn't appear then you probably selected the wrong source directory)
Pick the "Selected Changesets" option
Hit Next
Select the changesets you want to merge
I'm not sure if there's a way to do it from the workitem itself.
You may want to look into this tool:
http://wicreator.codeplex.com/Wiki/View.aspx?title=MergeByWI
This can be quite difficult, because afaik tfs does not support what is sometimes called "cherrypicking", i.e. merging a few otherwise unrelated changesets into a branch. Tfs expects that you merge the whole branch up to a certain version, without leaving any changessets out. I'm afraid what you're asking isn't directly possible.
You could do it manually, but for a large number of changesets it will be painful. The "links" tab in the workitem contains all changesets ids that were associated with the work item - that could give you some help.

Resources