SVN分支问题
创建分支时,选择以下选项有何含义?
在存储库中从以下位置创建副本:
- 存储库中的 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
简而言之:
根据创建分支的目的,您通常会选择前两个选项之一。第三个选项可能不太常用。
如果您想为特定目的进行一些探索性开发,或者您想开始为特定客户或其他东西创建不同的版本,您可以从 HEAD 进行分支。如果您需要对以前发布的软件版本进行修补,您将从过去分支。
In short:
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.
存储库中的 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).
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.
在 svn 中“创建分支”实际上只是复制存储库的某些子集。事实上,SVN Book 上的章节 分支说明了这一点。
如果您的目录结构如下所示...
,并且您的 trunk 网址为:
http://example.com/repos/project/trunk
,您将:创建一个名为
beta 的新分支
来自 HEAD,如下所示:这将立即在存储库中创建新分支,并且不会对本地副本执行任何操作。
从旧版本n创建一个名为
ancient
的新分支,如下所示:这与1完全相同,但使用特定版本。
从本地副本创建一个名为
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…
and your URL to trunk is:
http://example.com/repos/project/trunk
, you would:make a new branch named
beta
from HEAD like so:This will immediately create the new branch in the repository and doesn't do anything to your local copy.
make a new branch named
ancient
from an older revision n like so:This is exactly the same as 1, but uses the specific revision.
make a branch named
alpha
from your local copy, assuming your current directory istrunk
: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
: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.