问题描述
版本控制通常如何工作?是否将 diff 文件保存为带有哈希值的跟踪以验证跟踪?
how does version control usually work? does it save diff files as a trail with hashes to validate the trail?
推荐答案
不同的 VCS 使用不同的方法.例如,CVS 将为您提交的每个文件在服务器上创建一个文件.这本质上是一个 RCS 格式的文件;CVS 只是 RCS 的包装器,它对目录子树中的许多文件运行 RCS 命令(RCS 只能处理单个文件).
Different VCS use different approaches. CVS, for example, will create a file on the server for each file which you commit. This is essentially a file in RCS format; CVS is only a wrapper around RCS which runs the RCS commands over many files in a directory subtree (RCS can only work on single files).
RCS 文件包含更改列表(版本号、签入消息以及更改的数量).之后是当前 HEAD 版本的副本.其余文件是版本之间的差异(详细解释).
The RCS file contains a list of changes (version number, checkin message and how much was changed). After that comes a copy of the current HEAD version. The rest of the files are the diffs between the versions (long explanation).
这样,CVS 可以快速返回 HEAD 版本(这是最常请求的),并且可以计算其他版本.
This way, CVS can quickly return the HEAD version (which is most often requested) and it can compute the other versions.
CVS 不做任何验证;如果您的文件之一损坏,则需要备份.由于 CVS 基于 RCS,它不能版本目录也不能跟踪重命名.CVS 和 RCS 使用标准的 diff(1)
命令来创建差异.
CVS doesn't do any validation; if one of your files becomes corrupt, you need a backup. Since CVS is based on RCS, it can't version directories nor can it track renames. CVS and RCS use the standard diff(1)
command to create the diffs.
Subversion (SVN) 的工作原理类似,但添加了目录的版本控制和重命名.此外,SVN 使用了更好的 diff 算法 (xdelta),它提供了一个更小的存储库.
Subversion (SVN) works similarily but adds versioning of directories and renames. Moreover, SVN uses a better diff algorithm (xdelta) which gives a smaller repository.
For an explanation how Git works, see here.
这篇关于版本控制如何工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!