How to merge new files into another branch in TFS?

前端 未结 5 1926
温柔的废话
温柔的废话 2021-02-18 14:48

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

相关标签:
5条回答
  • 2021-02-18 15:03

    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.
    0 讨论(0)
  • 2021-02-18 15:03

    You could try to use the TF Merge command

    0 讨论(0)
  • 2021-02-18 15:07

    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.

    0 讨论(0)
  • 2021-02-18 15:07

    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.

    0 讨论(0)
  • 2021-02-18 15:08

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

    0 讨论(0)
提交回复
热议问题