In TFS, how can I cherry-pick a changeset to an unrelated branch?

霸气de小男生 提交于 2019-12-04 05:51:42

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.

The basic steps are:

  • 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

Its simpler to do it using Visual studio.

In Visual studio use the Source Control Merge wizard to merge the unrelated branches.

It has an option to merge selective changesets. The only restriction is that the changesets must be consecutive

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!