Skip to content
This repository has been archived by the owner on May 2, 2019. It is now read-only.

Commit

Permalink
add some png
Browse files Browse the repository at this point in the history
  • Loading branch information
dawncold committed Feb 23, 2011
1 parent 3312818 commit 2fbdca9
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions zh/03-git-branching/01-chapter3.markdown
Expand Up @@ -19,17 +19,17 @@

现在,Git 仓库中有五个对象:三个表示文件快照内容的 blob 对象;一个记录着目录树内容及其中各个文件对应 blob 对象索引的 tree 对象;以及一个包含指向 tree 对象(根目录)的索引和其他提交信息元数据的 commit 对象。概念上来说,仓库中的各个对象保存的数据和相互关系看起来如图 3-1 所示:

Insert 18333fig0301.png ![03-1](http://progit.org/figures/ch3/18333fig0301-tn.png)
![03-1](http://progit.org/figures/ch3/18333fig0301-tn.png)
图 3-1. 一次提交后仓库里的数据

作些修改后再次提交,那么这次的提交对象会包含一个指向上次提交对象的指针(译注:即下图中的 parent 对象)。两次提交后,仓库历史会变成图 3-2 的样子:

Insert 18333fig0302.png
![03-2](http://progit.org/figures/ch3/18333fig0302-tn.png)
图 3-2. 多次提交后的 Git 对象数据

现在来谈分支。Git 中的分支,其实本质上仅仅是个指向 commit 对象的可变指针。Git 会使用 master 作为分支的默认名字。在若干次提交后,你其实已经有了一个指向最后一次提交对象的 master 分支,它在每次提交的时候都会自动向前移动。

Insert 18333fig0303.png
![03-3](http://progit.org/figures/ch3/18333fig0303-tn.png)
图 3-3. 指向提交数据历史的分支

那么,Git 又是如何创建一个新的分支的呢?答案很简单,创建一个新的分支指针。比如新建一个 testing 分支,可以使用 `git branch` 命令:
Expand All @@ -38,7 +38,7 @@ Insert 18333fig0303.png

这会在当前 commit 对象上新建一个分支指针(见图 3-4)。

Insert 18333fig0304.png
![03-4](http://progit.org/figures/ch3/18333fig0304-tn.png)
图 3-4. 多个分支指向提交数据的历史

那么,Git 是如何知道你当前在哪个分支上工作的呢?其实答案也很简单,它保存着一个名为 HEAD 的特别指针。请注意它和你熟知的许多其他版本控制系统(比如 Subversion 或 CVS)里的 HEAD 概念大不相同。在 Git 中,它是一个指向你正在工作中的本地分支的指针。运行 `git branch` 命令,仅仅是建立了一个新的分支,但不会自动切换到这个分支中去,所以在这个例子中,我们依然还在 master 分支里工作(参考图 3-5)。
Expand Down

0 comments on commit 2fbdca9

Please sign in to comment.