如何将新文件合并到TFS中的另一个分支?

发布于 2024-12-10 19:38:13 字数 474 浏览 0 评论 0原文

好的,在 TFS 中,我们有一个主干分支和另一个分支,我们称之为辅助分支。我们已经在主干中创建了一个新文件,但是当尝试合并该特定文件时,它没有为我们提供合并到辅助分支的选项。我们假设这是因为辅助文件中不存在类似文件。

这是问题的原因吗?如果是,我们如何将新文件从主干获取到辅助

在这里,我们正在合并辅助中确实存在的文件。正如您所看到的,下拉列表列出了我们的所有三个分支(次要实际上是中间的分支): 在此处输入图像描述

现在,当我尝试合并在 trunk 之后创建的文件时辅助已分支,辅助不再列为目标分支。 在此处输入图像描述

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

南风几经秋 2024-12-17 19:38:13

尝试合并该特定文件

要理解 TFS,请记住更改的单位是更改集,并且签入和合并的是更改集(而不是文件)。

我们假设这是因为辅助文件中不存在类似文件

这是正确的 - 在目标分支所在的版本(变更集编号)中,该文件根本不存在,因此没有任何内容可以合并。

一般来说,通过在合并源对话框中选择特定的文件,您不会获得任何东西 - 正如它所说,它要求您选择源和目标分支。指定根分支,选择仅选定的变更集,TFS 将向您显示源中存在但尚未合并到目标的变更集列表。如果您只需要添加此新文件的文件,则可以在该列表中选择它。

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.

鹿童谣 2024-12-17 19:38:13

我认为这应该可以通过 VS GUI 实现,如下所示:

选择添加新文件的文件夹,然后将(整个文件夹)合并到您的辅助分支。
现在,该文件夹的所有已更改文件都会显示在您的待处理列表+您的新文件中。
撤消所有其他文件和文件。继续仅签入一个重要的文件。

有人可能会说,TFS 的这种限制实际上是有道理的:

  • 如果您对文件进行了其他更改,您就可以避免破坏您的辅助分支。
  • 如果您没有对任何其他文件进行其他更改,则合并您的文件仍然有意义,因为合并将仅包含您的新文件。

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.
月亮是我掰弯的 2024-12-17 19:38:13

“现在,当我尝试合并在辅助分支分支后在主干中创建的文件时,辅助分支不再被列为目标分支。”

为此,请右键单击“源代码管理资源管理器”中的文件,然后选择“分支”而不是“合并”。然后将弹出一个对话框来指定目标。

一般来说,最好合并主干和次要分支,而不是合并其中的各个部分(更容易保持分支随着时间的推移保持一致)。

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

深海夜未眠 2024-12-17 19:38:13

我认为原因只是你无法合并尚未分支的东西。请注意,如果您合并包含新文件的文件夹,它会显示操作为 [merge,branch],表示您正在将新文件分支为父文件夹合并的结果。据我所知,选择文件>合并与合并分支>分支而不是合并似乎是解决方案。我看到的唯一区别是历史记录列出了它有一个[分支]而不是一个[合并,分支]。在辅助分支中创建文件分支后,您可以合并分支之间对文件的更改。

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.

小镇女孩 2024-12-17 19:38:13

您可以尝试使用TF Merge命令

You could try to use the TF Merge command

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文