Eclipse 将分支合并到主干中
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2093028/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Eclipse Merge Branch into Trunk
提问by martin
I am trying to merge my development branch back into the trunk of my repo. Steps I took:
我正在尝试将我的开发分支合并回我的 repo 的主干中。我采取的步骤:
- Switch to trunk
- check that it is up to date, resolve any conflicts
- Go to Team->Merge
- Select URL : development branch
- Start Revision: Revision when branch was created
- End Revision: HEAD
- OK
- 切换到后备箱
- 检查它是否是最新的,解决任何冲突
- 转到团队->合并
- 选择 URL : 开发分支
- 开始修订:创建分支时的修订
- 结束修订:HEAD
- 好的
This should do the magic - it opens up the syncronize view which is fine, shows me all the conflicts, but there the problem happens:
这应该很神奇 - 它打开了很好的同步视图,向我展示了所有冲突,但问题发生了:
In the compare editor I see two files: Local File | Remote File (306)
在比较编辑器中,我看到两个文件:本地文件 | 远程文件 (306)
This is really strange, the revision number of the remote file is actually the one of the file in the working copy (trunk) and so is the content. The local file has the content of the file in the branch.
这真的很奇怪,远程文件的修订号实际上是工作副本(主干)中的文件之一,内容也是如此。本地文件具有分支中文件的内容。
Now the arrow shows correctly that I am merging from left to right (branch to trunk). This also happens when I click ok.
现在箭头正确显示我正在从左到右合并(分支到主干)。当我单击确定时也会发生这种情况。
BUT I can only move changes from right to left!!! That's not what I want - I do not want to overwrite the changes in the branches with the old content of the trunk. I want to move the content from left (branch) to right (trunk). But I can't even write in the right file.
但是我只能从右到左移动更改!!!那不是我想要的 - 我不想用主干的旧内容覆盖分支中的更改。我想将内容从左(分支)移到右(主干)。但我什至无法写入正确的文件。
I do not know why it writes remote file there?? It's clearly showing the working copy file in the remote file window, and the file from the branch (for merging) is shown in local file.
我不知道为什么它会在那里写远程文件??它在远程文件窗口中清楚地显示了工作副本文件,并且来自分支(用于合并)的文件显示在本地文件中。
Some bug in Subversive?
Subversive 中的一些错误?
Thx, Martin
谢谢,马丁
采纳答案by VonC
Merges are never been easy with subversive (as mentioned in this old SO question), so may be doing the merge externally (or with subclipse) would be easier here.
使用颠覆性的合并从来都不是一件容易的事(如在这个旧的SO 问题中提到的),因此在外部(或使用 subclipse)进行合并可能会更容易。
If your client and repository are both at least in SVN1.5, Subversive new merge capabilities are better, but still dangerous as illustrated by this thread.
如果您的客户端和存储库都至少在 SVN1.5 中,则 Subversive 新合并功能会更好,但仍然很危险,如该线程所示。
Since Subversive has been modified for SVN 1.5 the whole merge behavior has changed. One thing I really liked is the ability to choose what changes I wanted, apply that to my working copy and then commit to trunk.
Subversive now no longer does that but forces all changes onto your working copy and then you choose what to put in the trunk.This is not only undesirable behavior but it's also dangerous (if you ignore the possibility of a revert anyway). I prefer to commit things I know work. We have a release branch which gets changes which may or may not need to be migrated to the trunk.
由于 Subversive 已针对 SVN 1.5 进行了修改,因此整个合并行为发生了变化。我真正喜欢的一件事是能够选择我想要的更改,将其应用到我的工作副本,然后提交到主干。
Subversive 现在不再这样做,而是将所有更改强制到您的工作副本上,然后您选择将什么放入后备箱。这不仅是不受欢迎的行为,而且也是危险的(如果您无论如何都忽略了恢复的可能性)。我更喜欢提交我知道工作的事情。我们有一个发布分支,它获取可能需要或可能不需要迁移到主干的更改。
回答by zenaminati
Well this seemed mysterious at first, now I shall provide a decent stab at updating this answer for everyone. This regards merging using the SVN Subversive client for Eclipse:
好吧,起初这似乎很神秘,现在我将为每个人提供一个不错的更新这个答案的尝试。这涉及使用 Eclipse 的 SVN Subversive 客户端进行合并:
You are doing your merge correctly, starting in Trunk and then pointing to your file under your local Branch. Your files open up in the "Text Compare" window under the Team Synchronizing tab. If you do not see conflicts over in the left hand navigation column, then your merge has just happened. Yes, this is confusing and non-intuitive.
您正在正确地进行合并,从 Trunk 开始,然后指向本地分支下的文件。您的文件会在“团队同步”选项卡下的“文本比较”窗口中打开。如果您在左侧导航栏中没有看到冲突,那么您的合并刚刚发生。是的,这令人困惑且不直观。
What the Text Compare window offers you is the ability to undo your change (or any others that may have gotten into your merged file unawares) before you commit it. Remember that you are pulling in the file from Branch, so the idea is that the Branch file is in Trunk but in a kind of virtual limbo until finally committed, and changing or undoing unwanted changes here references the file in Branch (obviously). That is why you only have a one-way pipe (Trunk to Branch) to overwrite those changed merged into Trunk via your working copy. Your merge has taken place, but it's not quite official yet.
“文本比较”窗口为您提供的是在提交更改之前撤消更改(或任何其他可能不知道已进入合并文件的更改)的能力。请记住,您是从 Branch 拉入文件,所以这个想法是 Branch 文件在 Trunk 中,但在最终提交之前处于一种虚拟状态,并且在此处更改或撤消不需要的更改会引用 Branch 中的文件(显然)。这就是为什么您只有一个单向管道(Trunk to Branch)来覆盖那些通过您的工作副本合并到 Trunk 的更改。你的合并已经发生,但还不是很正式。
If all looks as it should, right click the file in the navigator window (left pane in my Eclipse Helios install) and choose Accept from the drop-down. Then click back over to your main code-viewing tab (in my installation it's PHP but it could be whatever you are using) and then commit the file to Trunk.
如果一切正常,请在导航器窗口(我的 Eclipse Helios 安装的左窗格)中右键单击该文件,然后从下拉列表中选择接受。然后单击返回到您的主要代码查看选项卡(在我的安装中它是 PHP,但它可以是您使用的任何内容),然后将文件提交到 Trunk。
If you want to test this, do a view of the file "as is" in Trunk before committing and you should see your changes reflected there if you have done your merge correctly. This appears to be the way it is working for me on an OSX Snow Leopard Macbook Pro. Not sure if it's the same for Windows or Linux folks. I assume it's essentially the same/similar process.
如果您想对此进行测试,请在提交之前在 Trunk 中“按原样”查看文件,如果您正确完成了合并,您应该会在那里看到您的更改。这似乎是它在 OSX Snow Leopard Macbook Pro 上对我来说有效的方式。不确定 Windows 或 Linux 人员是否相同。我认为它本质上是相同/相似的过程。
回答by Toskan
it's easy
这很简单
check out trunk with check out as... give a different project name.
签出主干并签出为... 给出不同的项目名称。
Now you have both locally as working copy, trunk you wanna commit to and the branch you are working on and whose changes you have comitted to the repository. Now rightclick the trunk project (and I mean the project, not single files) - merge - select the branch project (again, PROJECT) accept all changes to local copy commit what you need to trunk as used to all fine, delete trunk again and keep working on the branch
现在,您在本地拥有工作副本、要提交到的主干以及您正在处理的分支以及您已将其更改提交到存储库的分支。现在右键单击主干项目(我的意思是项目,而不是单个文件) - 合并 - 选择分支项目(再次,PROJECT)接受对本地副本的所有更改提交你需要的主干,因为一切正常,再次删除主干和继续在分支上工作
especially with branches this seems super easy and worked like a charm for me
尤其是在分支上,这看起来非常简单,对我来说就像一种魅力