使用 TortoiseSVN 如何将更改从主干合并到分支,反之亦然?
我一直在使用优秀且免费的 Version Control with Subversion 阅读有关 Subversion 1.5 的分支/合并的内容书。 我认为我了解如何使用 Subversion 命令行客户端来执行我最常需要的操作,这些操作是:
使用主干中的更改更新分支
从分支的工作目录运行:
合并分支到Trunk
从 trunk 的工作目录运行:
svn merge --reintegrate http://svn.myurl.com/proj/branches/mybranch
然而,我们使用 TortoiseSVN 1.5 作为 Subversion 的接口。 我想知道如何使用 TortoiseSVN 最好地执行这些操作。 新对话框在主菜单上提供了三个不同的选项。
- 合并一系列修订
- 重新集成分支
- 合并两个不同的树
据我所知,TortoiseSVN 总是使用以下语法执行 svn。
svn merge [--dry-run] --force From_URL@revN To_URL@revM 路径
此外,重新集成分支经常失败,并显示一条消息,指出某些目标尚未合并,因此无法继续,因此我不得不使用选项#3。
我的问题是:
- 如何使用 TortoiseSVN 1.5 将更改从主干合并到分支?
- 如何使用 TortoiseSVN 1.5 将分支合并到主干,无论是否使用重新集成方法?
- 我应该为每个选项使用上述哪些选项,为什么?
编辑
通过“空运行”测试我发现命令行Subversion操作
类似于选项#1 (合并修订范围)在 TortoiseSVN 中,只要我将修订范围留空即可。
I've been reading up on branching/merging with Subversion 1.5 using the excellent and free Version Control with Subversion book. I think that I understand how to use the Subversion command line client to perform the actions that I need most often, which are:
Update Branch with Changes from Trunk
From the branch's working directory run:
svn merge http://svn.myurl.com/proj/trunk
Merge Branch into Trunk
From the trunk's working directory run:
svn merge --reintegrate http://svn.myurl.com/proj/branches/mybranch
However, we are using TortoiseSVN 1.5 as our interface to Subversion. I would like to know how best to perform these operations with TortoiseSVN. The new dialog provides three different options on the main menu.
- Merge a range of revisions
- Reintegrate a branch
- Merge two different trees
From what I can gather, TortoiseSVN always executes svn with the following syntax.
svn merge [--dry-run] --force From_URL@revN To_URL@revM PATH
Additionally, reintegrate a branch often fails with a message stating that some targets have not been merged and so it cannot continue, and so I had to use option #3.
My questions are:
- How do I use TortoiseSVN 1.5 to merge changes from the trunk to a branch?
- How do I use TortoiseSVN 1.5 to merge the branch to the trunk, with and without the reintegrate method?
- Which of the above options should I use for each, and why?
EDIT
Through "dry run" testing I have found that the command line Subversion operation
svn merge http://svn.myurl.com/proj/trunk
is analogous to option #1 (Merge a Range of Revisions) in TortoiseSVN, as long as I leave the revision range blank.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
我无法正确遵循其他答案,这里有更多傻瓜指南...
您可以以任何一种方式执行此操作以转到
trunk ->; 分支
或分支-> 树干
。 我总是先做trunk -> 分支
修复那里的任何冲突,然后合并分支 -> 树干
。将主干合并到分支/标签
I couldn't properly follow the other answers, here's more of a dummies guide...
You can do this either way round to go
trunk -> branch
orbranch -> trunk
. I always first dotrunk -> branch
fix any conflicts there and then mergebranch -> trunk
.Merge trunk into a branch / tag
该行为取决于您的存储库具有的版本。 Subversion 1.5 允许 4 种类型的合并:
1.5 之前的 Subversion 只允许前 2 种格式。
从技术上讲,您可以使用前两种方法执行所有合并,但后两种方法启用 Subversion 1.5 的合并跟踪。
当您的存储库为 1.5+ 时,TortoiseSVN 的选项将范围或修订映射合并到方法 3,或者当您的存储库较旧时合并到方法一。
将功能合并到发布/维护分支时,您应该使用“合并一系列修订”命令。
仅当您想要将分支的所有功能合并回父分支(通常是主干)时,您才应该考虑使用“重新集成分支”。
最后一个命令 - 合并两个不同的树 - 仅当您想要跳出正常的分支行为时才有用。 (例如比较不同的版本,然后将差异合并到另一个分支)
The behavior depends on which version your repository has. Subversion 1.5 allows 4 types of merge:
Subversion before 1.5 only allowed the first 2 formats.
Technically you can perform all merges with the first two methods, but the last two enable subversion 1.5's merge tracking.
TortoiseSVN's options merge a range or revisions maps to method 3 when your repository is 1.5+ or to method one when your repository is older.
When merging features over to a release/maintenance branch you should use the 'Merge a range of revisions' command.
Only when you want to merge all features of a branch back to a parent branch (commonly trunk) you should look into using 'Reintegrate a branch'.
And the last command -Merge two different trees- is only usefull when you want to step outside the normal branching behavior. (E.g. Comparing different releases and then merging the differenct to yet another branch)
您应该使用“合并一系列修订”。
要将更改从主干合并到分支,请在分支工作副本内选择“合并修订范围”,然后输入主干 URL 以及要合并的开始和结束修订。
同样以相反的方式合并主干中的分支。
关于 --reintegrate 标志,请在此处查看手册: http://tortoisesvn.net/docs/release/TortoiseSVN_en/tsvn-dug-merge.html#tsvn-dug-merge-reintegrate
You should use "merge a range of revision".
To merge changes from the trunk to a branch, inside the branch working copy choose "merge range of revisions" and enter the trunk URL and the start and end revisions to merge.
The same in the opposite way to merge a branch in the trunk.
About the --reintegrate flag, check the manual here: http://tortoisesvn.net/docs/release/TortoiseSVN_en/tsvn-dug-merge.html#tsvn-dug-merge-reintegrate
查看 svnmerge.py。 它是命令行,不能被TortoiseSVN调用,但它更强大。 来自常见问题解答:
Take a look at svnmerge.py. It's command-line, can't be invoked by TortoiseSVN, but it's more powerful. From the FAQ:
Shift-右键单击该文件夹并选择 TortoiseSVN -> 全部合并
Shift-Right Click on the folder and select TortoiseSVN -> Merge All