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:项目

23 Nov 2008

[git_0]介绍

  1 diff --git a/text/01_Introduction/0_ Introduction.markdown b/text/01_Introduction/0_ Introduction.markdown
  2 deleted file mode 100644
  3 index 9c60fb9..0000000
  4 --- a/text/01_Introduction/0_ Introduction.markdown    
  5 +++ /dev/null
  6 @@ -1,54 +0,0 @@
  7 -## Welcome to Git ##
  8 -
  9 -Welcome to Git - the fast, distributed version control system.
 10 -
 11 -This book is meant to be a starting point for people new to Git to learn it
 12 -as quickly and easily as possible.
 13 -
 14 -
 15 -This book will start out by introducing you to the way Git stores data, to
 16 -give you the context for why it is different than other VCS tools.
 17 -This is meant to take you about 20 minutes.
 18 -
 19 -Next we will cover **Basic Git Usage** - the commands you will be using 90% of
 20 -the time.  These should give you a good basis to use Git comfortably for most
 21 -of what you're going to use it for.  This section should take you about 30
 22 -minutes to read through.
 23 -
 24 -Next we will go over **Intermediate Git Usage** - things that are slightly more
 25 -complex, but may replace some of the basic commands you learned in the first
 26 -section.  This will mostly be tricks and commands that will feel more
 27 -comfortable after you know the basic commands.
 28 -
 29 -After you have all of that mastered, we will cover **Advanced Git** - commands
 30 -that most people probably don't use very often, but can be very helpful in
 31 -certain situations.  Learning these commands should round out your day-to-day
 32 -git knowledge; you will be a master of the Git!
 33 -
 34 -Now that you know Git, we will then cover **Working with Git**.  Here we will go
 35 -over how to use Git in scripts, with deployment tools, with editors and more.
 36 -These sections are meant to help you integrate Git into your environment.
 37 -
 38 -Lastly, we will have a series of articles on **low-level documentation** that may
 39 -help the Git hackers who want to learn how the actual internals and protocols
 40 -work in Git.
 41 -
 42 -### Feedback and Contributing ###
 43 -
 44 -At any point, if you see a mistake or want to contribute to the book, you can
 45 -send me an email at [schacon@gmail.com](mailto://schacon@gmail.com), or you
 46 -can clone the source of this book at
 47 -[http://github.com/schacon/gitscm](http://github.com/schacon/gitscm)
 48 -and send me a patch or a pull-request.
 49 -
 50 -### References ###
 51 -
 52 -Much of this book is pulled together from different sources and then added to.  
 53 -If you would like to read some of the original articles or resources, please
 54 -visit them and thank the authors:
 55 -
 56 -* [Git User Manual](http://www.kernel.org/pub/software/scm/git/docs/user-manual.html)
 57 -* [The Git Tutorial](http://www.kernel.org/pub/software/scm/git/docs/gittutorial.html)
 58 -* [The Git Tutorial pt 2](http://www.kernel.org/pub/software/scm/git/docs/gittutorial-2.html)
 59 -* ["My Git Workflow" blog post](http://osteele.com/archives/2008/05/my-git-workflow)
 60 -
 61 diff --git "a/text/01_Introduction/0_ \344\273\213\347\273\215.markdown" "b/text/01_Introduction/0_ \344\273\213\347\273\215.markdown"
 62 new file mode 100644
 63 index 0000000..46154f3
 64 --- /dev/null
 65 +++ "b/text/01_Introduction/0_ \344\273\213\347\273\215.markdown"      
 66 @@ -0,0 +1,49 @@
 67 +## 欢迎使用 Git ##
 68 +
 69 +欢迎使用 Git ──快速的、分布式的版本控制系统(VCS)。
 70 +
 71 +这本书旨在为 Git 新人尽可能地提供一个快速的、容易的起点。
 72 +
 73 +这本书的开始将为你介绍 Git 储存数据的方式,并给你上下文,以标明为什么它有别于
 74 +其他 VCS 工具。这将花费你大约 20 分钟的时间。
 75 +
 76 +接下来我们将讲解 **Git 的基本用法** ── 这些命令是你 90% 的时间会用到的。这些
 77 +将给你一个良好的基础,使你舒服地用 Git 做绝大多数你想用它做的事情。你需要大概
 78 +30 分钟的时间来通读这一节。
 79 +
 80 +再接下来,我们将到达 **Git 中级用法**,事情稍微复杂一些,但也许可以替代一些你在
 81 +第一节学到的基本命令。这大多数是一些技巧,并且在知道基本命令后,你在学习这些命令,
 82 +将感觉更为轻松。
 83 +
 84 +在你掌握了以上知识后,我们将介绍 **高级 Git**,这些命令多数人都不会经常使用,但
 85 +在特定情形下却也非常有用。学习这些命令将助你跳出日常 Git 的知识;你将成为一个
 86 +Git 大师!
 87 +
 88 +现在你知道 Git 了,我们将接着介绍 **和 Git 协同工作**。这里我梦将覆盖如何在脚本中
 89 +使用 Git,结合实施工具,结合编辑器,以及更多。这些章节旨在协助你将 Git 整合到你的
 90 +(开发)环境中。
 91 +
 92 +最后,我们有一些列 **底层文档**,用来帮助 Git 黑客们学习 Git 的内在和协议。
 93 +
 94 +### 反馈和参与 ###
 95 +
 96 +任何时候,如果你看到了一个错误或者想要参与贡献这本书,你可以发邮件给我,地址是
 97 +[schacon@gmail.com](mailto://schacon@gmail.com),或者你可以从
 98 +[http://github.com/schacon/gitscm](http://github.com/schacon/gitscm)
 99 +克隆(clone)这本书的源代码,并给我发一个 patch 或者 pull-request。
100 +
101 +中文译本的邮件地址: [jick.nan@gmail.com](mailto://jick.nan@gmail.com)
102 +Git 克隆地址:<http://github.com/jicknan/gitscm>
103 +
104 +(P.S: 翻译这篇的时候,感谢某人在这寒冷的早晨帮我买鸡蛋饼 :P)
105 +
106 +### 参考资料 ###
107 +
108 +这本书的大部分都是从不同的来源整合并扩充而成的。如果你希望读一些原始的文章或者资源,
109 +请访问他们并感谢这些作者:
110 +
111 +* [Git User Manual](http://www.kernel.org/pub/software/scm/git/docs/user-manual.html)
112 +* [The Git Tutorial](http://www.kernel.org/pub/software/scm/git/docs/gittutorial.html)
113 +* [The Git Tutorial pt 2](http://www.kernel.org/pub/software/scm/git/docs/gittutorial-2.html)
114 +* ["My Git Workflow" blog post](http://osteele.com/archives/2008/05/my-git-workflow)

115 +

小更新:

Git 克隆地址:

  * 英文版分枝: book
  * 中文版分枝: book-zh