Ok, in TFS we have a main trunk branch and another branch, let\'s call it secondary. We have created a new file in the trunk but when trying to merge
I think this should be possible over the VS GUI as follows:
Select the folder where the new file was added and order a merge (of the whole folder) to your secondary branch.
Now all changed files of the folder appear in your pending list + your new file.
Undo all other files & proceed with checking in only the one file that matters.
One could argue that this restriction of TFS in fact makes sense:
You could try to use the TF Merge command
trying to merge that specific file
To understand TFS it helps to remember that the unit of change is the changeset, and it is changesets (not files) that are checked-in and merged.
We're assuming that it's because an analagous file does not exist in secondary
This is correct - at the version (changeset number) that the target branch is at, this file simply does not exist, so there is nothing to merge to.
In general, you don't gain anything by selecting a particular file in the merge source dialog - as it says, it asks you to select the source and targe branches. Specify the branches at their root, choose Selected changesets only
, and TFS will show you a list of changesets that exist in source but have not been merged to target. If you only want the one that added this new file, you can select it in that list.
I think the reason is just that you can't merge something that hasn't been branched. Notice if you merge the folder containing the new file, it says the action is [merge, branch] indicating you are branching the new file as the result of a merge of the parent folder. As far as I can tell, selecting the file > Merging & Branching > Branch, instead of Merge seems to be the solution. The only difference I see is the history then lists it has a [branch] rather than a [merge, branch]. After you've created a branch of the file in your secondary branch, you can merge changes to the file between branches.
"Now, when I try to merge a file which was created in trunk after secondary was branched, secondary is no longer listed as a target branch."
For that, right click on the file in Source Control Explorer and choose Branch instead of Merge. That will then bring up a dialog to specify the target.
Generally, you are better off merging trunk and secondary rather than pieces of it (easier to keep the branch consistent over time).