使用 Eclipse 在 SVN 中将分支合并到主干

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3611693/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 19:36:29  来源:igfitidea点击:

Merging of branch to trunk in SVN using Eclipse

eclipsesvn

提问by mona

I am looking forward to merge my codes which I developed in a branch of SVN to the trunk. I am using Eclipse and I have been using Team->Commit to commit my updates to the SVN. But I haven't done a merge before. Please help me with this. Thanks

我期待将我在 SVN 分支中开发的代码合并到主干中。我正在使用 Eclipse,并且我一直在使用 Team->Commit 将我的更新提交到 SVN。但是我之前没有做过合并。请帮我解决一下这个。谢谢

回答by dvanaria

  1. First of all make sure you are up to date. Update your working copy of the target branch, ie. where you are merging into. In this example we're working on the trunk of "core" and we want to grab the changes that have happened in the maintenance branch and merge them.
  2. Resolve any conflicts. There should be no conflicts at this stage between the working copy and the repository.
  3. Select the SVN merge option on the working copy. In Eclipse this is going to be found under the "Team" menu and called "Merge Branch". SVN: Merging in Eclipse
  4. Change the From URL to the specific branch you want to be merged into your working copy. In this example we're looking for the p400 maintenance branch (./core/branches/p400).
  5. Change the From Revision to the last revision that was merged into the target branch. Essentially you don't want to keep merging the whole branch history, you just want to include those changes since the last time you merged. There is no easy way to determine the last merge point at this time in Subversion. You have to review your message log and look for the last commit that talks about merging. If you are disciplined about the commit messages you use for merging this should be easy (see below). Make a note of what that revision is -- you'll need this later when you commit your changes. SVN: Merge with Eclipse
  6. Change the To Revision to the latest (i.e. head). Make a note of what that revision is -- you'll need this later when you commit your changes.
  7. Click Merge and wait. Depending on how big the differences are this may be quick or Eclipse my just fall over. If you have such an enormous change that you can't get it done in Eclipse you may need to make the range of revisions you are merging smaller. Or you may even have to skip certain revisions and do them manually if they are massive. We've had this problem from time to time when updating large third-party libraries. The vast majority of the time you will be fine.
  8. Review changes and resolve conflicts. Once the merge is complete, look through the changes made to your working copy and make sure you address any conflicts you find.
  9. Once all the changes have been resolved in the target working copy, check them in with a single commit. The reason you're not doing lots of commits is that these are changes that should have been documented in the branch from which you merged. The commit message needs to be in a specific format that details the merge and is easy to find in the future. We use the following format, but you can use anything that works for you -- as long as you stick to it.

    Merging [source] to [target]; [repository]. Merge rev [start]:[end]

  1. 首先确保你是最新的。更新目标分支的工作副本,即。你要融入的地方。在这个例子中,我们正在处理“核心”的主干,我们想获取维护分支中发生的更改并将它们合并。
  2. 解决任何冲突。在这个阶段,工作副本和存储库之间应该没有冲突。
  3. 在工作副本上选择 SVN 合并选项。在 Eclipse 中,这将在“团队”菜单下找到并称为“合并分支”。SVN:在 Eclipse 中合并
  4. 将 From URL 更改为要合并到工作副本中的特定分支。在这个例子中,我们正在寻找 p400 维护分支 (./core/branches/p400)。
  5. 将 From Revision 更改为合并到目标分支中的最后一个修订版。本质上,您不想继续合并整个分支历史记录,您只想包含自上次合并以来的更改。目前在 Subversion 中没有简单的方法来确定最后一个合并点。您必须查看您的消息日志并查找有关合并的最后一次提交。如果您对用于合并的提交消息有纪律,这应该很容易(见下文)。记下该修订是什么——稍后提交更改时将需要它。SVN:与 Eclipse 合并
  6. 将 To Revision 更改为最新的(即头部)。记下该修订是什么——稍后提交更改时将需要它。
  7. 单击合并并等待。根据差异有多大,这可能会很快,或者 Eclipse 我会摔倒。如果您有如此巨大的更改而无法在 Eclipse 中完成,您可能需要缩小要合并的修订范围。或者,您甚至可能不得不跳过某些修订,如果它们很大,则必须手动进行。我们在更新大型第三方库时不时遇到这个问题。大多数时候你会没事的。
  8. 查看更改并解决冲突。合并完成后,查看对工作副本所做的更改,并确保解决发现的任何冲突。
  9. 一旦目标工作副本中的所有更改都已解决,请通过一次提交将它们签入。您没有进行大量提交的原因是这些更改本应记录在您合并的分支中。提交消息需要采用特定格式,详细说明合并情况,并且将来很容易找到。我们使用以下格式,但您可以使用任何适合您的格式——只要您坚持使用它。

    合并 [源] 到 [目标];[存储库]。合并 rev [开始]:[结束]

Enjoy!

享受!

回答by MR AND

In eclipse we have an option to merge. Right click the project , you will see "Team" option and on clicking it you will see merge option. There are three different options you can see in the merge. enter image description here

在 Eclipse 中,我们可以选择合并。右键单击项目,您将看到“团队”选项,单击它您将看到合并选项。您可以在合并中看到三个不同的选项。在此处输入图片说明

To successfully merge the changes from the branch to the trunk, we need to switch the local workspace to the trunk (but make sure all the changes are committed to the branch before that). Once we do that we can use merge option and select "2 URLs" option. I put url for trunk as url 1 and the branch I wanted to merge as url 2. I could see all the incoming changes I selected "OK". All the changes are in my local now (at this point my workspace is linked to the trunk). Then I committed my changes to the trunk and hence merge from branch to the trunk was successful.

要成功地将分支的更改合并到主干,我们需要将本地工作区切换到主干(但请确保在此之前将所有更改提交到分支)。一旦我们这样做,我们就可以使用合并选项并选择“2 URLs”选项。我将主干的 url 设为 url 1,将要合并的分支设为 url 2。我可以看到所有传入的更改,我选择了“确定”。所有更改现在都在我的本地(此时我的工作区已链接到主干)。然后我将更改提交到主干,因此从分支到主干的合并成功。

回答by Deepa Dhanalakota

I would like to add for Point 8 .Review changes and resolve conflicts. ---

我想添加第 8 点。更改并解决冲突。---

When working on conflicts manually- when you do copy from right to left on chunks of code - Be careful Sometimes chunk of code gets added, sometimes it properly replaces the chunk. Make sure there is no duplicate chunk of code.

当手动处理冲突时——当你在代码块上从右向左复制时——小心有时代码块被添加,有时它正确地替换了块。确保没有重复的代码块。

Also, this is helpful-- What is the proper way to do a Subversion merge in Eclipse?

此外,这很有帮助——在 Eclipse 中进行 Subversion 合并的正确方法什么?