TortoiseSVN:使用 Switch 进行合并

TortoiseSVN: Using Switch to Merge

我正在与同一个中央存储库中的另一个团队合作。

他们有一个分支(我们称之为 theirBranch),我不允许编辑(可以查看、结帐,但不能更改)。

我有自己的分支 (myBranch),它最初是 theirBranch 的副本。在检查并处理它之后,"working copy",当我对它进行重大更改后,我将它提交回 myBranch。

目标:将 theirBranch 中的任何更改合并到 myBranch。

第一次尝试 - 是 "merge of two different trees"。

"This method covers the case when you want to merge the differences of two different branches into your working copy."

结果 - 代码中的任何差异都被标记为冲突 即使自从最初创建 myBranch 以来代码只是由我更改的。此外,一些增加的复杂性,我有一些树冲突,因为我从 myBranch 中删除了一些文件,这些文件仍然存在于 theirBranch 中。这棵树的冲突对我来说很重要。

问题一: 是否所有树冲突都需要手动 merged/resolved?

第二次尝试 - 使用 "switch" 将 theirBranch 与 myBranch 合并。切换回我的分支并提交。

据我了解,当在 (2) 个不同分支上的同一存储库中工作时,您可以切换工作副本链接到的存储库分支。完成后,您的工作副本和新分支之间的任何差异将是 "merged" 使用 "update"。

来自 TortoiseSVN 人:

切换-

Just as “Update-to-revision” changes the time window of a working copy to look at a different point in history, so “Switch” changes the space window of a working copy so that it points to a different part of the repository. It is particularly useful when working on trunk and branches where only a few files differ. You can switch your working copy between the two and only the changed files will be transferred.

更新-

This Subversion command pulls down the latest changes from the repository into your working copy, merging any changes made by others with local changes in the working copy.

结果 - 在我的工作副本中,任何不同的文件都被文件的 "theirBranch" 版本替换。

问题 2 - 为什么文件被替换而不是合并?

问题 3 - 为什么只存在于 theirBranch 中的 theirBranch 文件被放置在 myBranch 中并且没有树冲突?

请随时回答任何您知道答案的问题或任何关于实现我的目标的建议。谢谢。

首先是对您尝试的分析:
1) 合并两个不同的树
https://tortoisesvn.net/docs/release/TortoiseSVN_en/tsvn-dug-merge.html 中所示,如果满足以下条件,它可能适用于您的情况:
- 您有与 myBranch
链接的工作副本 - 然后你 select 在 TortoiseSVN window 中将 FROM myBranch 合并到 theirBranch window(而不是相反,正如我想的那样:它解释了你观察到的冲突)。
然而,当没有 merge-tracking 功能可用时,这种合并很有用,这可能不是你的情况。
2) 切换指令
这不是合并,而是本地工作副本与另一个分支(在您的情况下)的重新同步。因此,如果与切换前的 myBranch 相比,您没有任何本地更改,那么与切换后的 theirBranch 相比,您将不会有任何更改。正如您所观察到的,这意味着您的本地文件将被替换。这回答了您的问题 2 和 3。
Switch 命令不是合并,在您的情况下使用它可能非常危险(您最终可能会忘记您的本地工作副本与哪个分支链接)。

其次,我建议使用 "Merge a range of revisions",它似乎很适合您的情况。然而,您仍然有可能遇到树冲突:与所有其他冲突一样,您将不得不手动解决它们。这回答了你的问题 1.