TFS获取分支->回滚->向后合并并希望删除所有更改 [英] TFS getting Branch -> Rollback -> Merge backwards and wanting to erase all changes

查看:89
本文介绍了TFS获取分支->回滚->向后合并并希望删除所有更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们在项目的Dev分支中进行了一些更改(我们将其称为changeset1),这些更改实际上应该在新分支中完成。因此,我要解决的问题是在Dev分支的旁边创建一个新分支(我们称其为Dev2)。然后,我将Dev分支回滚到changeset1之前。所以现在代码库看起来像是在Dev2中完成的开发,而Dev却从未动过。

We had some changes committed (let's call it changeset1) in what we call the Dev branch of our project that really should've been done in a new branch. So what I did to fix it is create a new branch off of the Dev branch (let's call it Dev2). Then I rolled back the Dev branch to before changeset1. So now the code base looks like the development was done in Dev2 and Dev was never touched.

后来,我在Dev中进行了一些开发,将其合并到Stage中,然后然后产品。现在,我也尝试将这些更改合并到Dev2中,但是当我执行合并(在VS 2017中)时,它会自动合并所有内容,并且它想从changeset1中删除所有更改。我猜是因为我在changeset1之后回滚了Dev,所以它将其视为最新更改,并希望将该回滚合并到Dev2。如何才能将Dev2视为最新版本并将新的Dev更改合并到其中,而又不删除changeset1的更改?

Later, I then did some development in Dev, merged it to Stage, and then Prod. Now I'm trying to also merge those changes into Dev2 but when I perform the merge (in VS 2017) it auto-merges everything and it wants to delete all of the changes from changeset1. I guess because I rolled back Dev after changeset1, it sees that as the latest change and wants to merge that rollback to Dev2. How can I get it to see Dev2 as the latest and merge my new Dev changes into it without deleting changeset1's changes?

为澄清起见,Dev是两个Stage的父级

For clarification, Dev is the parent of both the Stage and Dev2 branches.

推荐答案

我想出了一种解决方法。因此,我想重申一下,我认为问题是我想要在Dev2中进行更改,但是我在创建Dev2之后回滚了Dev,因此回滚是最新的更改,因此合并希望保留回滚并删除我想要的更改远离Dev2。因此,我得出的结论是,我需要做的是以某种方式再次将这些更改应用于Dev2 ,就像它们是新编辑一样。

I figured out a way to resolve it. So to re-iterate, I think the problem was the changes I wanted were in Dev2, but I rolled back Dev after creating Dev2 so the rollback was the most recent change so the merge wanted to keep the rollback and delete the changes I wanted to keep from Dev2. So I came to the conclusion that what I need to do was somehow apply those changes to Dev2 again as if they were a new edit.

所以我要做的是:


  1. 将更改从changeet1移到Shelveset

  2. 将Dev合并到Dev2,从而删除了所需的更改

  3. 取消将更改集1 Shelveset搁置为Dev2

#1是最难的部分。首先,我创建了两个新的工作区:DevC0和DevC1。我将changeset1之前的变更集拉入DevC0,并将changeset1放入了DevC1。因此,DevC1现在拥有我感兴趣的所有更改,而DevC0没有。然后,我将所有更改的文件(使用BeyondCompare复制)从DevC1复制到DevC0(TFS文件夹/文件除外)。然后在命令行上,我对DevC0文件夹进行了 tf vc reconcile ,以使其能够识别我刚刚复制过来的所有更改。例如。 (在我的情况下,我实际上并不想 / deletes ):

#1 was the hardest part. First I created two new workspaces: DevC0 and DevC1. I pulled the changeset from before changeset1 into DevC0 and pulled changeset1 into DevC1. So now DevC1 has all the changes I'm interested in and DevC0 does not. I then copied all of the changed files (using BeyondCompare but I think you could just copy all your files except for the TFS folders/files too) from DevC1 to DevC0. Then at the command line, I did a tf vc reconcile on the DevC0 folder to allow it to recognize all the changes I just copied over. E.G. (I didn't actually want /deletes in my case):

tf vc /reconcile /promote /adds /deletes /diff /recursive [DevC0 itemspec]

(确保命令提示符的工作目录是映射到目标工作空间的目录。之后,所有差异现在在Visual Studio Team Explorer / Source Control Explorer中都显示为待定更改。因此,从那里我可以创建一个Shelveset。

(Make sure your command prompt's working directory is a directory mapped to your target workspace). After that, all of the differences now appear as pending changes in Visual Studio Team Explorer/Source Control Explorer. So from there I can create a Shelveset.

#2只是从Dev到Dev2的典型合并。它删除了所有更改,并使Dev2与Dev匹配。我不知道我是否需要在应用Shelveset之前先检查一下,但我确实需要。

#2 was just a typical merge from Dev to Dev2. It deleted all of the changes and made Dev2 match Dev. I don't know if I needed to check this in before applying the Shelveset but I did.

#3我的changeset1更改在我的Shelveset中,但Shelveset属于开发分支。幸运的是,Team Foundation Power Tools可以将Shelveset搁置到另一个分支。 EG:

#3 My changeset1 changes are in my Shelveset, but the Shelveset belongs to the Dev branch. Luckily, Team Foundation Power Tools can unshelve a Shelveset to a different branch. E.G:

tfpt unshelve /migrate /source:"[Dev server path]" /target:"[Dev2 server path]"

这将打开一个窗口,其中包含每个文件的合并选项。我手动检查了前几个,然后尝试自动合并全部。这样做相当于通过Visual Studio进行合并-在可能的情况下自动合并,并且在同一窗口中将冲突留给我。之后,似乎所有所需的更改现在都在Dev2中待更改,因此我将它们检入。

This opened a window with merge options for each file. I manually reviewed the first few then tried auto-merging all. That did the equivalent of what merging via Visual Studio does - it auto merged where possible and left the conflicts up to me in that same window. After that, it appeared all of the desired changes were now pending changes in Dev2 and I checked them in.

然后我尝试将Dev2合并回Dev,只是为了看看如果它能够正常运行,并且确实将所有更改合并到Dev中,并且将许多由原始回滚删除的更改标记为未删除。现在,我取消了从合并中的未决更改,直到我们准备好将此子分支合并到我们的主要Dev分支中。

I then tried a merge from Dev2 back to Dev just to see if it was going to behave correctly and it did merge all of the changes to Dev and marked many of the changes that were deleted by the original rollback as undeleted. For now, I undid pending changes from that merge until we are actually ready to merge this sub-branch of work into our main Dev branch.

这篇关于TFS获取分支->回滚->向后合并并希望删除所有更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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