24 Nov 2008

[git_02]Git 的基本对象模型

  1 diff --git a/text/02_Git_Object_Db_Basics/0_ Git_Object_Db_Basics.markdown b/text/02_Git_Object_Db_Basics/0_ Git_Object_Db_Basics.markdown
  2 index a73e0fe..013d849 100644
  3 --- a/text/02_Git_Object_Db_Basics/0_ Git_Object_Db_Basics.markdown    
  4 +++ b/text/02_Git_Object_Db_Basics/0_ Git_Object_Db_Basics.markdown    
  5 @@ -1,55 +1,51 @@
  6 -## The Git Object Model ##
  7 +## Git 对象模型 ##
  8  
  9 -### The SHA ###
 10 +### SHA 值 ###
 11  
 12 -All the information needed to represent the history of a
 13 -project is stored in files referenced by a 40-digit "object name" that
 14 -looks something like this:
 15 +表示一个项目历史的所有需要的信息都被储存在文件中,这些文件以一个 40 位
 16 +的"对象名称"引用,就像下面这个:
 17     
 18      6ff87c4664981e4397625791c8ea3bbb5f2279a3
 19     
 20 -You will see these 40-character strings all over the place in Git.
 21 -In each case the name is calculated by taking the SHA1 hash of the
 22 -contents of the object.  The SHA1 hash is a cryptographic hash function.
 23 -What that means to us is that it is virtually impossible to find two different
 24 -objects with the same name.  This has a number of advantages; among
 25 -others:
 26 -
 27 -- Git can quickly determine whether two objects are identical or not,
 28 -  just by comparing names.
 29 -- Since object names are computed the same way in every repository, the
 30 -  same content stored in two repositories will always be stored under
 31 -  the same name.
 32 -- Git can detect errors when it reads an object, by checking that the
 33 -  object's name is still the SHA1 hash of its contents.
 34 -
 35 -### The Objects ###
 36 -
 37 -Every object consists of three things - a **type**, a **size** and **content**.
 38 -The _size_ is simply the size of the contents, the contents depend on what
 39 -type of object it is, and there are four different types of objects:
 40 -"blob", "tree", "commit", and "tag".
 41 -
 42 -- A **"blob"** is used to store file data - it is generally a file.
 43 -- A **"tree"** is basically like a directory - it references a bunch of
 44 -    other trees and/or blobs (i.e. files and sub-directories)
 45 -- A **"commit"** points to a single tree, marking it as what the project
 46 -    looked like at a certain point in time.  It contains meta-information
 47 -    about that point in time, such as a timestamp, the author of the changes
 48 -    since the last commit, a pointer to the previous commit(s), etc.
 49 -- A **"tag"** is a way to mark a specific commit as special in some way.  It
 50 -    is normally used to tag certain commits as specific releases or something
 51 -    along those lines.
 52 -
 53 -Almost all of Git is built around manipulating this simple structure of four
 54 -different object types.  It is sort of its own little filesystem that sits
 55 -on top of your machine's filesystem.
 56 -
 57 -### Different from SVN ###
 58 -
 59 -It is important to note that this is very different from most SCM systems
 60 -that you may be familiar with.  Subversion, CVS, Perforce, Mercurial and the
 61 -like all use _Delta Storage_ systems - they store the differences between one
 62 -commit and the next.  Git does not do this - it stores a snapshot of what all
 63 -the files in your project look like in this tree structure each time you
 64 -commit. This is a very important concept to understand when using Git.
 65 +你会在 Git 的各个地方看到这些 40 个字符组成的字符串。在每一种情况下,这个名字通过
 66 +计算对象内容的 SHA1 哈希值取得。 SHA1 哈希值是一个密码学哈希函数。对我们来说,
 67 +这意味着事实上不可能根据同一个名字找到两个不同的对象。这具有很多优势,其中:
 68 +
 69 +- Git 可以很快地区分两个对象是不是相同的,只要比较名字。
 70 +- 因为在每个仓库中都以相同的方式计算对象名称,因此储存在两个仓库中的相同
 71 +  内容总是以相同的名字存储。
 72 +- Git 可以在读取一个对象的时候侦测错误,只要检查这个对象的名字是否仍然是它
 73 +  内容的 SHA1 哈希值。
 74 +
 75 +### 对象 ###
 76 +
 77 +每个对象包含三件事 ──**类型**,**大小**和**内容**。_大小_很简单,就是内容的
 78 +大小;内容则取决于对象的类型。对象有四种不同的类别: "blob", "tree", "commit"
 79 +和 "tag"。
 80 +
 81 +- 一个 **"blob"** 用来储存文件数据 ──它通常是一个文件。
 82 +- 一个 **"tree"** 基本上很像一个目录 ──它索引一组其他的 tree 或者/和
 83 +  blob (比如:文件和子目录)。
 84 +- 一个 **"commit"** 指向一个单独的 tree,作为项目在某个特定的时间点上的标记。
 85 +  它包含那个时间点的元信息,比如时间戳,最后 commit 为止的改变的作者,指向之前
 86 +  commit 的指针,等等。
 87 +- 一个 **"tag"** 是用来标记特定 commit 在某些方面特别的一种方法。它通常用来
 88 +  标记指定的 commit 作为特定的发行,或者累死的东西。
 89 +
 90 +Git 几乎所有的建设都是围绕这种四个不同的对象类型组成的简单结构。它是一种构建
 91 +在你机器的文件系统之上的自由小文件系统。
 92 +
 93 +### 和 SVN 的区别 ###
 94 +
 95 +需要重点指出的是,这和你以前所熟悉的大多数 SCM 系统都非常不同。Subversion, CVS,
 96 +Perforce, Mercurial 以及所有类似使用 _Delta 存储_ 的系统储存一个 commit 和下一个
 97 +commit 之间的差别。Git 不这么做 ──你每次 commit 时,它储存你项目里每次 commit
 98 +的 tree 结构的所有文件的快照。这是使用 Git 时需要理解的重要观念。
 99 +
100 +### 术语对照 ##
101 +
102 +- object: 对象
103 +- model: 模型
104 +- hash:哈希
105 +- repository: 仓库
106 +- project:项目

No comments:

Post a Comment