我在Subversion(以及一般的存储库)讨论中经常看到这些词。 在过去的几年里,我一直在我的项目中使用SVN,但是我从来没有掌握这些目录的完整概念。

它们是什么意思?


当前回答

一般来说(工具不可知的观点),分支是用于并行开发的机制。一个SCM可以有0到n个分支。Subversion是0。

Trunk is a main branch recommended by Subversion, but you are in no way forced to create it. You could call it 'main' or 'releases', or not have one at all! Branch represents a development effort. It should never be named after a resource (like 'vonc_branch') but after: a purpose 'myProject_dev' or 'myProject_Merge' a release perimeter 'myProjetc1.0_dev'or myProject2.3_Merge' or 'myProject6..2_Patch1'... Tag is a snapshot of files in order to easily get back to that state. The problem is that tag and branch is the same in Subversion. And I would definitely recommend the paranoid approach: you can use one of the access control scripts provided with Subversion to prevent anyone from doing anything but creating new copies in the tags area.

标签是最终的。其内容不应改变。从来没有。永远。你忘了发行通知里的一行字?创建一个新标记。淘汰或删除旧的。

现在,我读了很多关于“在某某分支中合并某某,然后最终在主干分支中合并”的内容。 这就是所谓的合并工作流,这里没有强制性的内容。这并不是因为你有一个主干分支,你必须合并回任何东西。

按照惯例,主干分支可以代表您的开发的当前状态,但这是一个简单的顺序项目,该项目具有:

没有“预先”开发(用于准备下一个下一个版本,这意味着这些更改与当前的“主干”开发不兼容) 没有大规模的重构(用于测试新的技术选择) 没有以前版本的长期维护

因为对于这些场景中的一个(或所有),你会得到四个“主干”,四个“当前开发”,而不是你在这些并行开发中所做的所有事情都必须合并回“主干”中。

其他回答

这就是关于软件开发的事情,没有一致的知识,每个人似乎都有自己的方式,但这是因为它是一个相对年轻的学科。

这是我简单的方法,

trunk - trunk目录包含最新的、已批准的和合并的工作主体。与许多人所承认的相反,我的箱子只用于干净、整洁、合格的工作,而不是一个开发区域,而是一个释放区域。

在某个给定的时间点上,当主干似乎已经准备好释放时,它就会被标记并释放。

分支——分支目录包含实验和正在进行的工作。分支下的工作一直停留在那里,直到被批准合并到主干中。对我来说,这是所有工作完成的区域。

例如:我可以有一个迭代-5分支用于产品的第5轮开发,可能有一个原型-9分支用于第9轮实验,等等。

tags—标签目录包含已批准的分支和中继发布的快照。每当一个分支被批准合并到主干中,或者一个发布是由主干组成的,一个被批准的分支或主干发布的快照就会在标记下生成。

我想有了标签,我可以很容易地在时间里来回跳转到感兴趣的点。

嗯,我不确定我同意尼克重新标签类似于一个分支。标签只是一个标记

Trunk would be the main body of development, originating from the start of the project until the present. Branch will be a copy of code derived from a certain point in the trunk that is used for applying major changes to the code while preserving the integrity of the code in the trunk. If the major changes work according to plan, they are usually merged back into the trunk. Tag will be a point in time on the trunk or a branch that you wish to preserve. The two main reasons for preservation would be that either this is a major release of the software, whether alpha, beta, RC or RTM, or this is the most stable point of the software before major revisions on the trunk were applied.

在开源项目中,不被项目涉众接受的主要分支可以成为分叉的基础——例如,与其他源代码共享共同起源的完全独立的项目。

分支和标记子树与主干的区别如下:

Subversion allows sysadmins to create hook scripts which are triggered for execution when certain events occur; for instance, committing a change to the repository. It is very common for a typical Subversion repository implementation to treat any path containing "/tag/" to be write-protected after creation; the net result is that tags, once created, are immutable (at least to "ordinary" users). This is done via the hook scripts, which enforce the immutability by preventing further changes if tag is a parent node of the changed object.

Subversion从1.5版开始还增加了与“分支合并跟踪”相关的特性,这样提交到分支的更改就可以合并回支持增量式“智能”合并的主干中。

我认为一些混淆来自标记概念和SVN中的实现之间的差异。对于SVN来说,标签是一个分支,它是一个副本。修改标签被认为是错误的,事实上,像TortoiseSVN这样的工具会警告你,如果你试图用../tags/..在路上。

在SVN中,标记和分支非常相似。

标签=在时间上定义的片段,通常用于发布

分支=在开发过程中定义的片段,通常用于1.0、1.5、2.0等主要版本,然后在发布时标记分支。这允许您继续支持产品版本,同时在主干中进行突破性的更改

Trunk =开发工作空间,这是所有开发应该发生的地方,然后从分支发布合并回来的更改。

当我在OpenCV 2计算机视觉应用编程烹饪书的作者的网站上查找时,我发现了这个关于SVN的很棒的教程,我想我应该分享一下。

他有一个关于如何使用SVN的教程,以及短语“trunk”、“tag”和“branch”的含义。

直接引用自他的教程:

The current version of your software project, on which your team is currently working is usually located under a directory called trunk. As the project evolves, the developer updates that version fix bugs, add new features) and submit his changes under that directory. At any given point in time, you may want to freeze a version and capture a snapshot of the software as it is at this stage of the development. This generally corresponds to the official versions of your software, for example, the ones you will deliver to your clients. These snapshots are located under the tags directory of your project. Finally, it is often useful to create, at some point, a new line of development for your software. This happens, for example, when you wish to test an alternative implementation in which you have to modify your software but you do not want to submit these changes to the main project until you decide if you adopt the new solution. The main team can then continue to work on the project while other developer work on the prototype. You would put these new lines of development of the project under a directory called branches.