简体   繁体   English

如何使用 TFS 使用 master 的更改更新当前分支?

[英]How to update current branch with changes from master using TFS?

I have a project code that uses Team Foundation Server (TFS) for revision control.我有一个使用 Team Foundation Server (TFS) 进行修订控制的项目代码。 I created a new branch named br-feature from main using Visual Studio 2019. Since then, my main branch changed.我使用 Visual Studio 2019 从main创建了一个名为br-feature的新分支。从那时起,我的main分支发生了变化。 I want to pull all the new changes from the main branch and onto the current br-feature branch to ensure everything works before I merge changes from br-feature into main .我想将所有新更改从main分支拉到当前的br-feature分支,以确保在我将更改从br-feature合并到main之前一切正常。

I do not see an option using Visual Studio to fast-forward current branch.我没有看到使用 Visual Studio 快进当前分支的选项。 How can I pull all the changes from my main branch into br-feature using TFS?如何使用 TFS 将main分支中的所有更改拉入br-feature

From the comments the repo is TFVC.从评论来看,repo 是 TFVC。 TFS can host TFVC and git repos. TFS 可以托管 TFVC 和 git 存储库。

To work with TFVC:使用 TFVC:

  • Ensure that you have a configured and working Team Project connection.确保您具有已配置且有效的 Team Project 连接。 (From the 'Team' menu choose 'Manage Connections...'.) (从“团队”菜单中选择“管理连接...”。)
  • Ensure that in the dialog opened by the 'Tools --> Options...' menu that in the 'Source Control' section in 'Plug-in Selection' that "Visual Studio Team Foundation Server" is an option.确保在“工具 --> 选项...”菜单打开的对话框中,在“插件选择”的“源代码管理”部分中,“Visual Studio Team Foundation Server”是一个选项。 (The plug-in selection should update based on the selected repo.) (插件选择应根据所选的存储库进行更新。)
  • If you haven't already, you will need to connect to the TFVC repo and establish a local workspace.如果您还没有,您将需要连接到 TFVC 存储库并建立一个本地工作区。 Both branches will need to be mapped to your workspace.这两个分支都需要映射到您的工作区。
  • In the 'Team Explorer' window, click the 'Home' button.在“团队资源管理器”window 中,单击“主页”按钮。 In the 'Home' pane, click the 'Source Control Explorer' link to open the 'Source Control Explorer' window.在“主页”窗格中,单击“源代码管理资源管理器”链接以打开“源代码管理资源管理器”window。
  • In the 'Source Control Explorer' window, when you right-click on a branch in the context menu there should be a 'Branching and Merging --> Merge...' option.在“Source Control Explorer”window 中,当您右键单击上下文菜单中的分支时,应该会出现“Branching and Merging --> Merge...”选项。

In TFVC branches are hierarchal.在 TFVC 中,分支是分层的。 The question description suggests that br-feature is a child branch of main .问题描述表明br-featuremain的子分支。 It should be straight-forward to merge from main (the parent branch) to br-feature (a child branch).main (父分支)合并到br-feature (子分支)应该是直截了当的。

TFVC is file-based, not snapshot-based like git. Each file has its own chain of deltas. TFVC 是基于文件的,而不是像 git 那样基于快照的。每个文件都有自己的增量链。 TFVC changesets are equivalent to git commits but are a set of deltas to files. TFVC 变更集相当于 git 次提交,但它是文件的一组增量。

Because TFVC is file-based, file adds and file deletes are somewhat special.因为 TFVC 是基于文件的,所以文件添加和文件删除有些特殊。 To keep the order of changesets correct, always merge parent to child before child to parent.为了保持变更集的顺序正确,请始终先将父项合并到子项,然后再将子项合并到父项。 ie ensure that changes in main are merged to br-feature and br-feature is up to date with main before merging br-feature to main .即确保main中的更改合并到br-feature并且br-feature在将br-feature合并到main之前与main保持同步。 The 'order' is important with how file adds and deletes are interpreted. “顺序”对于文件添加和删除的解释方式很重要。

With the branch hierarchy the auto-merge logic is able to perform a three-way compare: the current 'target' file, the incoming changed 'source' file, and the common ancestor for both.通过分支层次结构,自动合并逻辑能够执行三向比较:当前“目标”文件、传入的已更改“源”文件以及两者的共同祖先。 But the branch hierarchy can be very limiting.但是分支层次结构可能非常有限。

When you choose 'Merge...` from the context menu, the 'Merge' dialog will open.当您从上下文菜单中选择“合并...”时,“合并”对话框将打开。 The branch you clicked on will be selected as the source branch and you will be able to select the target branch.您单击的分支将被选择为源分支,您将能够 select 目标分支。 (The merge is from 'source' to 'target'.) (合并是从“源”到“目标”。)

The "All changes up to a specific version" option is what you want to use.您要使用的是“特定版本的所有更改”选项。 It will default to T which is the most recent revision (somewhat like HEAD with git).它将默认为T ,这是最新的修订版(有点像带有 git 的HEAD )。

(In the 'Merge' dialog you will see language about a 'merge relationship' - that means there is a parent/child relationship between the branches. You will also see mention of a 'baseless merge' - that means there is no parent/child relationship. The auto-merge logic doesn't support baseless merges. If you do a baseless merge all changes need to be manually merged.) (在“合并”对话框中,您会看到有关“合并关系”的语言 - 这意味着分支之间存在父/子关系。您还会看到提及“无基础合并” - 这意味着没有父/子关系。自动合并逻辑不支持无基础合并。如果您执行无基础合并,则所有更改都需要手动合并。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2025 STACKOOM.COM