Creating partial branches in TFS

One of the less known features in TFS is the ability to create partial branches. A partial branch is where you create a branch with only a set of subtrees of the source branch. There are a number of reasons why you might want to do it, including saving disk space on the server, saving time on merging, etc.

The reason it is not a very visible feature, is that it is enabled by the fact that branch / merge command respect your target working folder mappings.

To create a partial branch:

C:\TEMP\ws>tf dir trunk /r

2 item(s)

The next part is a bit non-intuitive as you need to cloak out the path in target space, even though it doesn't exist as yet:

C:\TEMP\ws>tf workfold /cloak branch\qa

C:\TEMP\ws>tf branch trunk branch


C:\TEMP\ws>tf checkin /i
Checking in branch: branch

Checking in branch: dev

Changeset #7 checked in.

Keep in mind that you must have the mappings in every workspace you use to merge, as not having them will cause the branch to convert to a full branch as shown.

C:\TEMP\ws>tf merge trunk branch /r
There are no changes to merge.

C:\TEMP\ws>tf workfold /decloak branch\qa

C:\TEMP\ws>tf merge trunk branch /r
merge, branch: $/proj/trunk/qa;C6 -> $/proj/branch/qa