Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to merge new files into another branch in TFS?

Tags:

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 that specific file, it does not give us the option to merge to the secondary branch. We're assuming that it's because an analagous file does not exist in secondary.

Is this the cause of the problem and if so, how can we get that new file from the trunk into secondary?

Here, we are merging a file that does exist in secondary. As you can see, the dropdown lists all three of our branches (secondary is actually the middle one): enter image description here

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. enter image description here

like image 473
T Nguyen Avatar asked Oct 19 '11 04:10

T Nguyen


People also ask

How do I merge files from one branch to another in TFS?

Right-click the main branch, point to Branching and Merging, and then click Merge… The Source Control Merge Wizard appears. On the Select the source and target branches for the merge operation screen: In Source branch, specify the main branch. In Target branch, specify the development branch.


2 Answers

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.

like image 155
AakashM Avatar answered Oct 27 '22 09:10

AakashM


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:

  • If you 've made additional changes to the files you 're hereby protected from breaking your secondary branch.
  • If you haven't made additional changes to any other files, it still makes sense to merge your, since the merge will only contain your new file.
like image 45
pantelif Avatar answered Oct 27 '22 10:10

pantelif