在TFS中,如何将变更集挑选到不相关的分支上? [英] In TFS, how can I cherry-pick a changeset to an unrelated branch?

查看:100
本文介绍了在TFS中,如何将变更集挑选到不相关的分支上?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要清理的TFS结构非常混乱(由于我的前任).现在,我遇到一种情况,我需要有选择地将变更集从一个分支带到另一个分支,而这些分支之间没有父/子关系,而且我不希望这些更改通过它们的共享干线传递.我该怎么办?

I have a very messy TFS structure that I am trying to clean up (thanks to my predecessor). I now have a situation where I need to bring changesets selectively from one branch to another where they don't have a parent/child relationship and I don't want those changes to pass through their shared trunk. How can I do this?

我尝试了无基础合并-在TFS中,我如何进行无基础合并-告诉我没有要合并的更改.

I have tried a baseless merge - In TFS, how do I do a baseless merge on specific changesets? - which told me that there were no changes to merge.

我想要实现的是这样的 TFS:货架集可以还原到另一个位置吗?除了变更集以外.

What I want to achieve is something like this TFS : Can a shelveset be restored to another location? except with a changeset.

在GIT中,我认为这将是一个简单的选择.

In GIT I think this would be a simple cherry-pick.

我的结构如下:

   Y-C1-C2-C3
  /
X-------------
    \
     Z

问题是如何在不通过X的情况下将C2从Y变成Z?

And the question is how do I get C2 from Y into Z without passing through X?

推荐答案

我们也有类似的情况,但是,在我们的情况下,我们将多个分支进行无基础的合并,变成了临时"构建分支.我们能够做到这一点的唯一方法是利用TFS API编写自己的实用程序.

We have a similar situation, though, in our case, we do a baseless merge from multiple branches into a "scratch" build branch. The only way we were able to do this is by writing our own utility leveraging the TFS API.

好消息是,您应该可以用不到几百行代码来完成此操作.

The good news is, you should be able to accomplish this in less than a couple hundred lines of code.

基本步骤是:

  • 连接到TFS
  • 获取VersionControlServer的实例(我们将其称为VCS)
  • 创建工作区
  • 执行VCS.GetChangeset()
  • 遍历Changes以获取已更改项目的列表
  • 对从源分支到目标分支的每个项目执行Workspace.Merge.
  • 检入目标分支中的项目.
  • 删除工作区
  • Connect to TFS
  • Get an instance of the VersionControlServer (let's call it VCS)
  • Create a workspace
  • Do a VCS.GetChangeset()
  • Iterate through the Changes to get a list of items that have changed
  • Perform a Workspace.Merge for each of the items from your source branch to your destination branch.
  • Check in the items in the destination branch.
  • Delete workspace

这篇关于在TFS中,如何将变更集挑选到不相关的分支上?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆