如何将代码分支到 SVN 的另一个存储库?

发布于 2024-07-15 11:47:38 字数 297 浏览 9 评论 0原文

我们有两个存储库,一个用于当前代码,一个用于项目管理。

现在我们需要将代码分支到项目管理存储库。

SVN给了我一个错误,我在文档中发现SVN无法完成这项工作(不同的存储库),

所以我导出代码并签入项目存储库。

问题:

  • 如何将代码分支到另一个存储库?
  • 对于我的情况,如何将更改从项目存储库移回 到当前存储库? (我还没有测试它,但我认为差异或补丁可能有效)

PS:我知道有一个主干/分支方式,但我们使用两个存储库。

We have two repositories, one for current code and one for project management.

Now we need to branch code to the project management repository.

SVN gives me an error, and I found in the documentation that SVN cannot do this work (different repository),

So I export the code and check in to the project repository.

The questions:

  • how to branch code to another repository?
  • for my case, how can I move the changes back from the project repository
    to the current repository? (I haven't test it yet, but I think a diff or patch may work)

PS: I know there is a trunk/branch way, but we use two repositories.

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

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

发布评论

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

评论(6

ㄟ。诗瑗 2024-07-22 11:47:38

如果我没猜错的话,您想将版本控制下的内容从存储库添加到另一个存储库吗? 如果是这样,您可能应该看看 svnsync这可以帮助您合并不同的存储库。

否则,保留两个存储库并添加 external 定义(链接)使它们共存。 这样你就不必费心去破坏任何东西。

If I got it right you want to add contents already under version control from a repository to another ? If that's it you should probably have a look on svnsync which helps you merging different repositories.

Otherwise it may be simpler to keep the two repositories and add external definitions (links) to make them coexist. This way you won't have to bother to much about breaking anything.

夏雨凉 2024-07-22 11:47:38

TortoiseSVN 提供了“在此处复制并添加这些文件”功能,但从 SVN 1.5.5 开始,不支持此功能。 我还没有使用 1.6.0 进行测试,

将文件从存储库 A 中右键拖动(不是正常的左键拖动)到存储库 B 中的目录中,然后释放鼠标。 将出现一个菜单,询问您想做什么。 我认为有 4 个选项可供选择(除了正常的操作系统选项)。 选择最合适的一个。

TortoiseSVN offers a "copy and add these files here" feature, but as of SVN 1.5.5, this feature was not supported. I have not yet tested it with 1.6.0

right-drag (not a normal left-drag) your files from repo A into a directory within repo B and release the mouse. A menu will appear asking what you want to do. There are, I think, 4 options to choose from (other than the normal OS options). Choose the one that is most appropriate.

嘴硬脾气大 2024-07-22 11:47:38

官方的 svn-book 引用了一个名为 svn_load_dirs.pl 的脚本,您可以使用它来简化此过程。 看看在线手册

The official svn-book refers to a script that you can use to make this process easier, called svn_load_dirs.pl. Take a look at the online manual

私野 2024-07-22 11:47:38

如果就责任而言,您指的是存储库(感谢布莱尔),那么您发现无法分支到另一个存储库。 但是,如果您的代码和项目相关,那么将它们放在同一个存储库中是有意义的。 你会想更多地了解 svn 并更好地使用它。 例如,“trunk”只是一个目录名称,因此您可以为项目使用一个名称,为代码使用一个单独的名称。 尽管使用这些特定的词,我们大多数人都希望“代码”位于“项目”内部。

无论如何,如果您离开存储库,您将丢失所有历史记录,并且失去所有分支或合并的机会。 因此,您需要重新考虑您的组织。 或者使用不同的版本控制系统来完成您想要的操作。

If, by responsibility, you mean repository (thanx, Blair), you found that you can't branch to another repository. But if your code and your project are related, then it makes sense to have them in the same repository. You will want to learn more about svn and use it better. For instance, "trunk" is just a directory name, so you can have one for the project, and a separate one for the code. Although, using those particular words, most of us would expect "code" to be inside "project".

Anyway, if you go outside of a repository, you lose all history and you lose all chance of branching or merging. So you need to rethink your organization. Or use a different version control system that does what you want.

桃扇骨 2024-07-22 11:47:38

@andrew-edgecombe 已经(间接)提到了“供应商分支”,这似乎是可能的。 这个概念似乎在以后的 SVN 版本中得到了一些更新,如 版本 1.8 文档 已经提到了使用纯 SVN 命令的此过程 - 使用以下命令创建远程存储库的副本(分支):

svn copy http://remote_v1 local

并稍后合并新的通过 2-URL 合并进行更新:

svn merge http://remote_v1 http://remote_v2 local

我想说相同的 2-URL 合并也可以用于将本地更改合并回原始存储库。 有关更多详细信息,请参阅链接文档中的“来自外部存储库的供应商分支”一章。

It seems to be possible with "Vendor Branches", already (indirectly) mentioned by @andrew-edgecombe. This concept seems to receive some updates in later SVN versions, as the version 1.8 documentation already mentions this process with pure SVN commands - to make a copy (a branch) of a remote repository with:

svn copy http://remote_v1 local

and to later merge new updates by the 2-URL merge:

svn merge http://remote_v1 http://remote_v2 local

I would say the same 2-URL merger can be used also to merge local changes back to the original repo. See the chapter "Vendor Branches from Foreign Repositories" in the linked documentation for additional details.

安穩 2024-07-22 11:47:38

您应该将所有代码放在一个存储库中。

它可能看起来像这样:

name/trunk/src
name/branches/dev/src

或者,用您所用的话来说:

name/current-code/src
name/project/src

然后,您可以轻松地来回 svn merge

You should have all the code in one repository.

It could look like this:

name/trunk/src
name/branches/dev/src

Or, in the words you used:

name/current-code/src
name/project/src

Then, you can easily svn merge back and forth.

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