SVN分支问题

发布于 2024-09-03 11:44:12 字数 119 浏览 4 评论 0原文

创建分支时,选择以下选项有何含义?

在存储库中从以下位置创建副本:

  • 存储库中的 HEAD 修订版本
  • 存储库的特定修订版本
  • 工作副本

When creating a branch, what are the implications of selecting the following?

Create copy in the repository from:

  • HEAD revision in the repository
  • Specific revision the repository
  • Working copy

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

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

发布评论

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

评论(4

旧人 2024-09-10 11:44:12

简而言之:

  • 从 HEAD 修订版创建是从“现在”开始创建一个分支,其中“现在”是提交到存储库的最新版本
  • 从特定修订版创建是从过去的某个点开始创建分支(由其标识) 从工作副本创建修订版号
  • 有点像从将来的某个点开始创建分支(您的工作副本,尚未提交)

根据创建分支的目的,您通常会选择前两个选项之一。第三个选项可能不太常用。

如果您想为特定目的进行一些探索性开发,或者您想开始为特定客户或其他东西创建不同的版本,您可以从 HEAD 进行分支。如果您需要对以前发布的软件版本进行修补,您将从过去分支。

In short:

  • creating from the HEAD revision is creating a branch starting from "now", where "now" is the latest version committed to the repository
  • creating from a specific revision is creating a branch starting from a point in the past (identified by its revision number)
  • creating from the working copy is sort of like creating a branch starting from a point in the future (your working copy, as yet uncommitted)

Depending on the purpose for creating the branch, you will usually choose one of the first two options. The third option is probably less commonly used.

You would branch from the HEAD if you want to do some exploratory development for a particular purpose, or you want to start creating a different version for a specific customer or something. You would branch from the past if you need to make a patch to a previously released version of your software.

溺ぐ爱和你が 2024-09-10 11:44:12

存储库中的 HEAD 修订版
SVN 采用编号最高的修订版,即最后上传的修订版。

存储库的具体修订
您可以选择您想要的版本。

工作副本
修订版就像现在在您的本地工作区中一样(未提交)。

HEAD revision in the repository
SVN takes the Revision with the highest number so the one which was uploaded last.

Specific revision the repository
You can select the revision you would like to get.

Working copy
The revision like it is right now in your local workspace (not comitted).

憧憬巴黎街头的黎明 2024-09-10 11:44:12

HEAD 将使分支成为存储库最新提交版本的副本。

特定的修订将导致分支成为存储库特定时间点的副本。

工作副本根据工作副本的最新修订创建一个分支,然后也提交所有“正在进行的”更改。

编辑:
选择工作副本的示例。

您使用最新版本的主干更新工作副本,开始进行一些小的更改。

几个小时后,您意识到这项工作比您预期的要大,您应该创建一个分支。

此时从工作副本创建分支,然后有效地创建分支,就像您在开始时完成的一样。

HEAD will cause the branch to be a copy of the latest committed version of the repository.

Specific revision will cause the branch to be a copy at a specific point in time of the repository.

Working copy creates a branch based on your working copy's latest revision and then commits to this all of your "in progress" changes as well.

EDIT:
An example for choosing Working Copy.

You update your working copy with the latest version of the trunk to start making some minor changes.

You realise after a few hours that the job was bigger than you expected and you should've created a branch.

Creating a branch from Working Copy at this point then effectively creates the branch as if you had done it at the beginning.

香橙ぽ 2024-09-10 11:44:12

在 svn 中“创建分支”实际上只是复制存储库的某些子集。事实上,SVN Book 上的章节 分支说明了这一点

如果您的目录结构如下所示...

  • 项目
    • 树干
    • 分支机构
    • 标签

,并且您的 trunk 网址为:http://example.com/repos/project/trunk,您将:

  1. 创建一个名为 beta 的新分支 来自 HEAD,如下所示:

    svn 复制 http://example.com/repos/project/trunk http://example.com/repos/project/branches/beta
    

    这将立即在存储库中创建新分支,并且不会对本地副本执行任何操作。

  2. 从旧版本n创建一个名为ancient的新分支,如下所示:

    svn copy -rn http://example.com/repos/project/trunk http://example.com/repos/project/branches/ancient
    

    这与1完全相同,但使用特定版本。

  3. 从本地副本创建一个名为 alpha 的分支,假设您当前的目录是 trunk

    <前><代码>cd ../
    svn cp 主干分支/alpha

    这将制作您请求的副本,但在本地进行。根据 SVN 书籍,不鼓励这样做,因为它比在存储库服务器上进行复制要花费更长的时间(其中复制操作基本上是免费的)。

    当您输入 svn help copy 时,还会列出此警告:

    <块引用>

    警告:为了与以前版本的 Subversion 兼容,
    使用两个工作副本路径(WC -> WC)执行的副本将不会
    联系存储库。因此,默认情况下,他们可能无法
    从副本源传播合并跟踪信息
    到达目的地。

根据我的经验,通常使用1方式。 2 用于一些罕见的情况,涉及对早期分支的复杂补丁,而 3 从来没有用(根据文档,缓慢且可能危险)。因此,请坚持使用1,除非您有令人信服的理由使用其他两个之一。

"Creating a branch" in svn is really just making a copy of some subset of your repository. In fact, the SVN Book chapter on branching says as much.

If your directory structure looks like this…

  • project
    • trunk
    • branches
    • tags

and your URL to trunk is: http://example.com/repos/project/trunk, you would:

  1. make a new branch named beta from HEAD like so:

    svn copy http://example.com/repos/project/trunk http://example.com/repos/project/branches/beta
    

    This will immediately create the new branch in the repository and doesn't do anything to your local copy.

  2. make a new branch named ancient from an older revision n like so:

    svn copy -r n http://example.com/repos/project/trunk http://example.com/repos/project/branches/ancient
    

    This is exactly the same as 1, but uses the specific revision.

  3. make a branch named alpha from your local copy, assuming your current directory is trunk:

    cd ../
    svn cp trunk branches/alpha
    

    This will make the copy you requested, but does it locally. According to the SVN book, this is discouraged because it takes a lot longer than making the copy on the repository server (where the copy operation is essentially free).

    There's also this caveat listed when you type svn help copy:

    WARNING: For compatibility with previous versions of Subversion,
    copies performed using two working copy paths (WC -> WC) will not
    contact the repository. As such, they may not, by default, be able
    to propagate merge tracking information from the source of the copy
    to the destination.

In my experience, way 1 is typically used. 2 is used in some rare cases involving complicated patches to earlier branches, and 3 is never useful (and according to the documentation, slow and possibly dangerous). So stick with 1 unless you have a compelling reason to use one of the other two.

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