返回文章列表

Git学习笔记-Git内部原理

新的项目使用git来进行版本管理,git在离线的版本管理方面非常的棒,这样一来其分布式版本管理的优势就会很明显了。 跟传统的CVS和SVN等版本管理工具来比,git可谓是用的是最“笨”的办法来进行版本管理。 我们知道CVS和SVN进行版本管理时,一个文件被创建后,更改后,再次提交只记录版...

2 分钟阅读

新的项目使用git来进行版本管理,git在离线的版本管理方面非常的棒,这样一来其分布式版本管理的优势就会很明显了。

跟传统的CVS和SVN等版本管理工具来比,git可谓是用的是最“笨”的办法来进行版本管理。

我们知道CVS和SVN进行版本管理时,一个文件被创建后,更改后,再次提交只记录版本间的差异,也就是在CVS和SVN的版本管理系统中,一个文件只有一个完整的副本,我们获取的某些版本下的文件都是通过记录的差异,然后从原始的副本计算得来。

而git呢? 则是任何改动后的提交都是记录一个完整的副本。如果是多个人完成一个项目,那么各自完成各自负责的部分并本地提交,最后只要将各自的git系统合并即可,有冲突处理冲突,没有冲突的就直接加进来,这样很方便分布式版本管理。

接下来我们看看git的内部原理,英文说明比较简单,也就不做翻译了:

The Objects:

Every object consists of three things - a type, a size and content. The size is simply the size of the contents, the contents depend on what type of object it is, and there are four different types of objects: "blob", "tree", "commit", and "tag".

A "blob" is used to store file data - it is generally a file.
A "tree" is basically like a directory - it references a bunch of other trees and/or blobs (i.e. files and sub-directories)
A "commit" points to a single tree, marking it as what the project looked like at a certain point in time. It contains meta-information about that point in time, such as a timestamp, the author of the changes since the last commit, a pointer to the previous commit(s), etc.
A "tag" is a way to mark a specific commit as special in some way. It is normally used to tag certain commits as specific releases or something along those lines.

.git下的目录说明:

objects 目录存储所有的数据内容

refs 目录存储指向数据(分支)的提交对象的指针

HEAD 文件指向当前分支

index 文件保存了暂存区域信息

评论交流

暂无评论,欢迎留下你的想法