使用 TortoiseSVN 进行分支和合并的最简单方法是什么?

发布于 2024-08-05 06:46:46 字数 43 浏览 3 评论 0原文

使用 TortoiseSVN 进行分支和合并的真正简单的“如何”是什么?

What is a really simple "how to" to do branching and merging using TortoiseSVN?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

掩于岁月 2024-08-12 06:46:46

假设您的工作目录正在主干上工作:

右键单击“根工作文件夹”(该术语始终指 Windows 资源管理器)并执行 svn update 将您的工作文件夹更新到最新的主干。

确保你拥有的东西是稳定的。

右键单击根工作文件夹并执行 svn commit 以确保所有本地更改都提交到主干。

右键单击根工作文件夹并执行 svn repo-browser

如果您的存储库中还没有分支文件夹:右键单击主干文件夹上方的文件夹,然后执行“创建文件夹”并创建一个分支文件夹(例如,如果您的主干是http:// /myserver/svn/MyRepository/MyProj/Trunk,创建http://myserver/svn/MyRepository/MyProj/Branches)。

右键单击主干文件夹并执行复制到: 并输入分支的新文件夹名称。例如:http://myserver/svn/MyRepository/MyProj/Branches/MyNewBranch。 (不要担心这会浪费大量空间......这称为“廉价副本”......它实际上不会复制文件的内容,除非它们发生变化)。

关闭存储库浏览器。

右键单击您的工作文件夹根目录,然后执行:svn switch 并选择新分支的文件夹名称(例如,http://myserver/svn/MyRepository/MyProj/Branches/MyNewBranch )。将其他所有内容保留为默认值。

现在在你的分支上工作。当您到达里程碑时,右键单击根工作文件夹并执行 svn commit 来提交到您的分支。 (这在后备箱中看不到)。

如果其他人正在同一分支上工作,请定期从根工作文件夹执行 svn update 。这将从分支更新。 (它不会从主干获取任何更新。)

无论其他人是否在同一分支上工作,您都应该定期合并来自主干的更改,以确保您的分支以后集成不会太困难。要进行定期合并:右键单击工作文件夹根目录并执行svn merge。选择“合并一系列修订”。在“合并来源的 URL”下,选择主干(例如,http://myserver/svn/MyRepository/MyProj/Trunk)。将修订范围保留为空白,并保留其他所有内容。单击“下一步”。保留所有内容并单击合并。确保一切仍然有效...如果不行则修复它。一旦您满意,请从工作根文件夹定期进行 svn update ,以从分支进行更新(即使您是唯一在分支上工作的人,这也是必要的,以满足 SVN 的要求)。然后执行 svn commit 将合并的主干更改提交到分支。您可以根据需要定期重复此步骤多次。

一旦您的分支准备好集成,请最后一次执行上述步骤并进行最终测试。对分支进行最终提交。

右键单击根工作文件夹并执行另一个 svn switch,这次切换到主干(例如,http://myserver/svn/MyRepository/MyProj/Trunk )。这基本上会“撤销”您在分支上所做的所有工作,但不用担心......您会恢复您的工作。 (它还会报告您分支中未更改的文件的大量更新,但这些只是“SVN 属性”更改...不用担心它们。)

右键单击您的工作文件夹并执行 svn 合并。这次,选择“重新集成分支”。对于 URL,输入您的分支(例如,http://myserver/svn/MyRepository/MyProj/Branches/MyNewBranch)。保留其余部分并单击“下一步”。保留所有内容并单击合并。您现在拥有在分支上完成的所有工作,以及来自主干的最新工作。

做最后的测试。一切都应该有效,因为这应该与您在分支中的上次测试中拥有的文件集相同。右键单击根工作文件夹并执行 svn commit。提交所有内容,甚至是您不在分支中处理的文件(它们只有“SVN 属性”更改,但提交它们可以帮助 SVN 跟踪所有修订)。

主干现在拥有您所有的分支工作以及您在分支上工作时在主干中完成的所有工作,并且一切正常。此外,SVN 拥有所有文件的完整历史记录,甚至是您在分支上工作时签入的修订版本。

可选:进入 Repo 浏览器,右键单击您的分支文件夹(例如,http://myserver/svn/MyRepository/MyProj/Branches/MyNewBranch)并执行“删除”操作。这不会对主干产生任何影响,并且您不再需要分支。 (即使你真的很偏执,也别担心,因为如果你真的需要的话,你甚至可以随时从 Repo 浏览器取回已删除的分支。)

请随时发表评论!

Assuming your work directory is working from the trunk:

Right-click on the "root work folder" (this term always refers to Windows Explorer) and do svn update to update your work folder to the latest trunk.

Make sure what you have is stable.

Right-click on the root work folder and do svn commit to make sure any local changes are committed to the trunk.

Right-click on the root work folder and do svn repo-browser.

If you don't already have a branches folder in the repository: right-click on the folder just above the trunk folder and do "create folder" and create a branches folder (for example, if your trunk is http://myserver/svn/MyRepository/MyProj/Trunk, create http://myserver/svn/MyRepository/MyProj/Branches).

Right-click on the trunk folder and do Copy To: and put in the new folder name for your branch. For example: http://myserver/svn/MyRepository/MyProj/Branches/MyNewBranch. (Don't worry that this will waste a lot of space... this is called a "cheap copy" ... it doesn't actually copy the contents of files unless they change).

Close Repo-browser.

Right click your work folder root, and do: svn switch and choose the folder name of your new branch (for example, http://myserver/svn/MyRepository/MyProj/Branches/MyNewBranch). Leave everything else at the default.

Now work on your branch. When you get to milestones, right-click on the root work folder and do svn commit to commit to your branch. (This will not be seen in the trunk).

If others are working on the same branch, periodically do svn update from the root work folder. This will update from the branch. (It will NOT get any updates from the trunk.)

Whether or not others are working on the same branch, you should periodically merge changes from the trunk to make sure your branch won't be too hard to integrate later. To do the periodic merge: right-click on the work folder root and do svn merge. Select "Merge a Range of Revisions". Under "URL to merge from", choose the trunk (for example, http://myserver/svn/MyRepository/MyProj/Trunk). Leave Revision Range blank and leave everything else alone. Click Next. Leave everything alone and click Merge. Make sure everything still works... fix it if not. Once you are satisfied, do a regular svn update from the work root folder to update from the branch (this is necessary even if you are the only one working on the branch, to satisfy SVN). Then do svn commit to commit the merged trunk changes to the branch. You can repeat this step periodically as many times as you want.

Once your branch is ready to integrate, do the above step one last time and do your final testing. Do a final commit to the branch.

Right click on your root work folder and do another svn switch, this time switching to the trunk (for example, http://myserver/svn/MyRepository/MyProj/Trunk). This will have the effect of essentially "undoing" all the work you've done on your branch, but don't worry... you will get your work back. (It will also report a lot of updates to files you didn't change in your branch, but these are just "SVN property" changes... don't worry about them.)

Right click on your work folder and do svn merge. This time, choose "Reintegrate a Branch". For the URL, put in your branch (for example, http://myserver/svn/MyRepository/MyProj/Branches/MyNewBranch). Leave the rest alone and click Next. Leave everything alone and click Merge. You now have all the work you've done on your branch, as well as up-to-date work from the trunk.

Do a final test. Everything should work because this should be the same set of files you had in your last test in the branch. Right-click on your root work folder and do an svn commit. Commit everything, even files that you didn't work on in your branch (they just have "SVN property" changes but committing them helps SVN keep track of all the revisions).

The trunk now has all your branch work as well as all the work that was done in the trunk while you were working on your branch, and it all works. In addition, SVN has the complete history of all the files, even the revisions that were checked in while you were working on your branch.

Optional: go into Repo-browser, right-click on your branch folder (for example, http://myserver/svn/MyRepository/MyProj/Branches/MyNewBranch) and do "delete". This will have no effect on the trunk, and you don't need the branch any more. (Even if you are really paranoid, don't worry, because you can even get your deleted branch back from Repo browser at any time if you really need to.)

Please feel free to comment!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文