简体   繁体   English

TFS/TFVC 合并选定的变更集与分支之间的 git 樱桃挑选

[英]TFS/TFVC merge selected changeset vs git cherry-pick between branches

We will be migrating our TFS/TFVC repository to Git.我们将把我们的 TFS/TFVC 存储库迁移到 Git。 In TFVC we used to have a trunk based development with long lasting release maintenance branches.在 TFVC 中,我们曾经有一个基于主干的开发,具有持久的发布维护分支。 Bug fixes on release branches have to be merged back to the trunk.发布分支上的错误修复必须合并回主干。 Sometimes smaller features have to be carried over from trunk to a release branch.有时较小的功能必须从主干转移到发布分支。 In TFVC we did this by "merging" individual (or small groups of) changesets from one branch to the other.在 TFVC 中,我们通过将单个(或一小组)变更集从一个分支“合并”到另一个分支来做到这一点。 The resulting changesets were marked as "merge", although I don't exactly know what that implies for TFVC, especially considering future merge operations.生成的变更集被标记为“合并”,尽管我不完全知道这对 TFVC 意味着什么,尤其是考虑到未来的合并操作。

So I imagine the branch graph to look something like this: (Although note that TFVC never displays any graphs)所以我想象分支图看起来像这样:(尽管请注意 TFVC 从不显示任何图表)

-A--B--C---D--E--F---    trunk
  \       /    \
   G--H--I--J---K--L-    release-x

(Here the release branch has been created from A, I->D is a bugfix merge, E->K is a feature-forward) But maybe I'm wrong. (这里的发布分支是从 A 创建的,I->D 是错误修复合并,E->K 是功能转发)但也许我错了。 In this case could someone explain what a TFVC merge changeset really does?在这种情况下,有人可以解释 TFVC 合并变更集的真正作用吗?

I've been told that an equivalent way of doing in Git is cherry-picking individual commits.有人告诉我,在 Git 中做的等效方法是挑选个人提交。 However, on the resulting branch graphs, I don't see any link between the branches following a cherry-pick commit.但是,在生成的分支图上,我看不到樱桃选择提交后分支之间的任何链接。 I am aware that cherry-picking is not technically a merge operation and thus history relation between the branches is not carried over.我知道樱桃采摘在技术上不是合并操作,因此分支之间的历史关系不会被继承。 Is there something I am missing?有什么我想念的吗? Is there a better way of carrying over such small commits from one branch to another, yet still retain some merge information?有没有更好的方法将如此小的提交从一个分支转移到另一个分支,但仍保留一些合并信息? I DO NOT want to merge the entire branch.我不想合并整个分支。 As for example changesets B,C or H must remain isolated from each other branch.例如变更集 B、C 或 H 必须与其他分支保持隔离。

When Cherry pocking you can add the -x option to have git add a message to the commit-message of each cherry-picked commit:当 Cherry pocking 时,您可以添加-x选项以让 git 将消息添加到每个cherry-picked提交的提交消息中:

-x When recording the commit, append a line that says "(cherry picked from commit …)" to the original commit message in order to indicate which commit this change was cherry-picked from. -x记录提交时,append 在原始提交消息中显示“(cherry pick from commit ...)”一行,以指示此更改是从哪个提交中挑选出来的。 This is done only for cherry picks without conflicts.这仅适用于没有冲突的樱桃采摘。 Do not use this option if you are cherry-picking from your private branch because the information is useless to the recipient.如果您是从您的私人分支中挑选的,请不要使用此选项,因为该信息对收件人无用。 If on the other hand you are cherry-picking between two publicly visible branches (eg backporting a fix to a maintenance branch for an older release from a development branch), adding this information can be useful.另一方面,如果您在两个公开可见的分支之间进行挑选(例如,将修复从开发分支向后移植到维护分支以获取旧版本),添加此信息可能很有用。

This is the closest you'll get.这是您将得到的最接近的。 A cherry picked commit it recorded as a new commit on she target branch, not as a reverse of forward integration.一个樱桃选择的提交它记录为她目标分支上的一个新提交,而不是作为前向集成的反向。

Git doesn't do "partial merges" since git stores the status of the worktree as a "version". Git 不执行“部分合并”,因为 git 将工作树的状态存储为“版本”。 TFVC stores the workspace versions of individual tiles instead. TFVC 改为存储单个图块的工作区版本。

What you're seeing are 2 very different things.你所看到的是两个非常不同的东西。

In TFVC you see a branch graph that is clearly defined through branch objects that have a defined parent branch.在 TFVC 中,您会看到通过具有已定义父分支的分支对象明确定义的分支图。 Each integration between those branches is visualized, since the merge stores which files were merged, which changesets were part of that merge and over which branch relationship these were merged.这些分支之间的每个集成都是可视化的,因为合并存储了哪些文件被合并,哪些变更集是该合并的一部分,以及这些被合并的分支关系。 A changeset in TFVC (closest thing to a commit in git) is also a very different thing. TFVC 中的变更集(最接近 git 中的提交)也是一个非常不同的东西。 For one, a changeset can span multiple branches, even repositories, and a changeset contains 1 or more changes to files.一方面,一个变更集可以跨越多个分支,甚至是存储库,并且一个变更集包含对文件的 1 个或多个更改。

In Git a branch is just a special pointer to a commit somewhere in the commit graph.在 Git 中,分支只是指向提交图中某处提交的特殊指针。 Parentage is calculated (based on the commit graph) and branches can freely merge without respecting a preconfigured hierarchy.亲子关系是计算出来的(基于提交图),分支可以自由合并,而无需考虑预配置的层次结构。 The visualization shows the relationships between commits, not branches.可视化显示提交之间的关系,而不是分支之间的关系。 A special type of commit, the merge, stores when a new commit was created from the basis of 2 or more other commits.一种特殊类型的提交,即合并,存储从 2 个或更多其他提交的基础创建新提交的时间。 The relation to these commits is stored, not the names of the branches that happened to point to these commits.与这些提交的关系被存储,而不是恰好指向这些提交的分支的名称。 A Commit stores the changes to the worktree.提交将更改存储到工作树。 One or more branches may point to that commit.一个或多个分支可能指向该提交。

Since a cherry-pick replays the changes on one branch in the commit tree onto another, it's not recorded as a merge where multiple sets of commits are linked together.由于樱桃选择将提交树中一个分支上的更改重播到另一个分支上,因此它不会记录为将多组提交链接在一起的合并。 Instead, it's recorded as a new commit that happens to have the same diff (and potentially not even that if you needed to do conflict resolution).相反,它被记录为恰好具有相同差异的新提交(如果您需要进行冲突解决,甚至可能没有差异)。

By adding the -x flag the relationship is stored in the comments.通过添加-x标志,关系存储在注释中。

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

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