简体   繁体   English

svn和git版本化模型的区别

[英]svn and git versioning models difference

I would like to know what is the difference between versioning approaches suggested by git (or other DVCSs) and subversion (or other CVCSs). 我想知道git(或其他DVCS)和subversion(或其他CVCS)建议的版本控制方法有什么区别。

Here is what I found on http://www.xsteve.at/prg/vc_svn/svn.txt regarding this topic: 以下是我在http://www.xsteve.at/prg/vc_svn/svn.txt找到的有关此主题的内容:

Subversion mananges versioned trees as first order objects (the repository is an array of trees), and the changesets are things that are derived (by comparing adjacent trees.) Systems like Arch or Bitkeeper are built the other way around: they're designed to manage changesets as first order objects (the repository is a bag of patches), and trees are derived by composing sets of patches together. Subversion mananges将树版本化为一阶对象(存储库是树的数组),并且变更集是派生的东西(通过比较相邻树。)像Arch或Bitkeeper这样的系统是相反构建的:它们被设计为将变更集作为一阶对象(存储库是一包补丁)进行管理,并通过将补丁集合在一起来派生树。

But it's not clear how subversion repository stores changes, whether it contain oldest variant of versioned file and so on. 但目前尚不清楚subversion存储库如何存储更改,是否包含版本化文件的最旧版本等等。 Why couldn't we generate a bunch of patches as in case of git, for example? 例如,为什么我们不能像git一样生成一堆补丁呢? It's always mentioned as a principal difference between svn and git which simplifies/complexifies merges, but, unfortunately, I still do not get the idea. 它总是被提到作为svn和git之间的主要区别,它简化/复合了合并,但不幸的是,我仍然没有得到这个想法。

There's a nice explanation about the main differences between VCS based on changesets and on snapshots at Martin's blog . 关于基于变更集的VCS与Martin博客上的快照之间的主要区别,有一个很好的解释。 I'll not repeat it here. 我在此不再重复。

However, I would stress one point that may not be obvious at first. 但是,我要强调一点,一开始可能并不明显。 Changeset based VCSs make it really easy to track merges, which is much more difficult for systems like Subversion, which is based on snapshots. 基于变更集的VCS使得跟踪合并变得非常容易,对于像Subversion这样基于快照的系统来说这要困难得多。

In a changeset based VCS, merges are simply changesets (or commits, as they're called in git) which have more than one parent changeset. 在基于变更集的VCS中,合并只是具有多个父变更集的变更集(或提交,因为它们在git中调用)。 The graphical representation of the repository usually shows a DAG (Directed acyclic graph) where the nodes represent changesets and the arrows represent parent-child relationships. 存储库的图形表示通常显示DAG(有向无环图),其中节点表示变更集,箭头表示父子关系。 When you see a node with more than one parent you know exactly what kind of merge occurred there. 当您看到一个包含多个父节点的节点时,您确切知道那里发生了哪种类型的合并。

In Subversion, "merge tracking" is something new. 在Subversion中,“合并跟踪”是一种新的东西。 Up until version 1.4 there was no such concept, so that in order to know about the history of merges you had to make notes in the log messages of your commits. 直到版本1.4,没有这样的概念,所以为了了解合并的历史,你必须在你的提交的日志消息中做笔记。 Version 1.5 implemented merge tracking to make it easier to perform repeated merges from one branch to another without forcing the user to be explicit about revision ranges and the like. 版本1.5实现了合并跟踪,以便更容易地执行从一个分支到另一个分支的重复合并,而不强制用户明确关于修订范围等。 This is implemented with a property (svn:mergeinfo) associated with the directory receiving the merge. 这是通过与接收合并的目录关联的属性(svn:mergeinfo)实现的。 It tracks which revisions have been already merged from which branches. 它跟踪哪些修订已经从哪些分支合并。 This is enough to infer which revisions should be merged in subsequente merges. 这足以推断应该在子序列合并中合并哪些修订。 But it doesn't make it easy to draw graphs showing the merge history, which is something you would like to see frequently as you work in a complex project with several developers. 但是,绘制显示合并历史记录的图表并不容易,当您在与多个开发人员的复杂项目中工作时,这是您希望经常看到的内容。

Git is arranged with version trees as first-order objects in principle. Git原则上安排了版本树作为一阶对象。 That is, you deal with a graph of commit objects, each of which has a one-to-one relationship with a tree that is the state at that revision. 也就是说,您处理提交对象的图形,每个提交对象与树的一对一关系,该树是该修订的状态。

Note that how these are actually stored can be very different. 请注意,实际存储它们的方式可能非常不同。 Git started out simply compressing each file and tree/commit object individually. Git开始只是单独压缩每个文件和树/提交对象。 As I understand it, packing objects into a single file and storing just deltas for some objects was added much later. 据我所知,将对象打包到一个文件中并且稍后只存储了一些对象的增量。

So in fact, although patches seem to be ubiquitous in git user interfaces, they are in fact no relation to how the data is stored- the deltas that are stored in the pack files are binary-level deltas, not text-style diffs at all. 事实上,尽管补丁似乎在git用户界面中无处不在,但事实上它们与数据的存储方式无关 - 存储在pack文件中的增量是二进制级别的增量,而不是文本样式的差异。 。 Git will apply deltas to get objects and then diff them again to produce the patch on demand. Git将应用增量来获取对象,然后再次对它们进行差异化以按需生成补丁。 This is in contrast to, for instance, CVS which inherited a latest-version-plus-reverse-deltas storage system from RCS. 这与例如从RCS继承了最新版本加反向增量存储系统的CVS形成对比。

Based on what you quoted, it appears that Git and SVN are actually more similar than either is to CVS, for example. 根据你所引用的内容,看起来Git和SVN实际上比CVS更相似,例如。

Late and partial answer. 迟到和部分回答。 I didn't think the following had been clarified above: 我认为上面没有澄清以下内容:

Important terms: 重要条款:

CVCS = C entralized Version Control System CVCS = C内置版本控制系统
DVCS = D istributed Version Control System (used by Git) DVCS = D归属版本控制系统(由Git使用)

REPOSITORY = A project's file tree, ie a directory with one or more subdirectories, with all of the many files for a single project. REPOSITORY =项目的文件树,即包含一个或多个子目录的目录,包含单个项目的所有文件。 For example: 例如:

./Project1/README
./Project1/myprogram.c
./Project1/Makefile
./Project1/images/1.gif
./Project1/images/2.gif

Centralized: 集中:

One (centralized) Repository shared by everyone. 每个人共享一个(集中式)存储库。

Usage: 用法:

  • A user checks out a file they want to edit, (ie gets a copy of that file from the remote repository), 用户签出他们想要编辑的文件(即从远程存储库获取该文件的副本),
  • They edit the file locally on their own computer, and then 他们在自己的计算机上本地编辑文件,然后
  • They check the file back into the central repository, (ie copy it back to the central repository which records the changes and makes the changes now available to other users). 他们将文件检入中央存储库(即将其复制回中央存储库,该存储库记录更改并使更改现在可供其他用户使用)。

Permission to make changes is granted to all users. 授予所有用户的权限。

Distributed: 分散式:

One read only Repository shared by everyone, then at a minimum a full copy of that Repository at each user's location. 每个人共享一个只读存储库, 然后至少在每个用户的位置存储该存储库的完整副本。

In other words every user makes a copy of the entire project tree onto their local machine, or copies the entire file tree from the primary repository. 换句话说,每个用户都将整个项目树的副本复制到其本地计算机上,或者从主存储库复制整个文件树。

Usage: 用法:

  • After a user makes a local edit 用户进行本地编辑后
  • They can then submit the edit back to the central Repository to have it possibly included and thus shared with others. 然后,他们可以将编辑提交回中央存储库,以便将其包含在内,从而与其他人共享。

Permission to make changes is controlled by the project owner who controls the primary repository. 进行更改的权限由控制主存储库的项目所有者控制。 (In git we have a "pull request", or a request to the project owner who controls the central Repository, to pull in the new changes.) (在git中,我们有一个“拉取请求”,或者是对控制中央存储库的项目所有者的请求,以引入新的更改。)

I've oversimplified this, to focus on the primary differences between centralized and distributed. 我过度简化了这一点,专注于集中式和分布式之间的主要区别。 (Now I admit that I'm still learning how the changes are actually recorded that you had asked about, and hope to update this once I fully understand this.) (现在我承认我还在学习如何实际记录您所询问的更改,并希望在我完全理解这一点后更新此内容。)

Ref: This is a good more complete article. 参考: 是一篇更完整的文章。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM