-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgit-fu-xi-gong-gu-2.html
179 lines (168 loc) · 9.46 KB
/
git-fu-xi-gong-gu-2.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="author" content="Won" />
<meta name="copyright" content="Won" />
<meta name="keywords" content="git, It, " />
<title>git 复习巩固(2) · Tugqi Biz
</title>
<link href="http://cdn-images.mailchimp.com/embedcode/slim-081711.css" rel="stylesheet" type="text/css">
<link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/css/bootstrap-combined.min.css" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="http://wbowam.github.io/theme/css/style.css" media="screen">
<link rel="stylesheet" type="text/css" href="http://wbowam.github.io/theme/css/solarizedlight.css" media="screen">
<link rel="shortcut icon" href="http://wbowam.github.io/theme/images/favicon.ico" type="image/x-icon" />
<link rel="apple-touch-icon" href="http://wbowam.github.io/theme/images/apple-touch-icon.png" />
<link rel="apple-touch-icon" sizes="57x57" href="http://wbowam.github.io/theme/images/apple-touch-icon-57x57.png" />
<link rel="apple-touch-icon" sizes="72x72" href="http://wbowam.github.io/theme/images/apple-touch-icon-72x72.png" />
<link rel="apple-touch-icon" sizes="114x114" href="http://wbowam.github.io/theme/images/apple-touch-icon-114x114.png" />
<link rel="apple-touch-icon" sizes="144x144" href="http://wbowam.github.io/theme/images/apple-touch-icon-144x144.png" />
<link rel="icon" href="http://wbowam.github.io/theme/images/apple-touch-icon-144x144.png" />
</head>
<body>
<div id="content-sans-footer">
<div class="navbar navbar-static-top">
<div class="navbar-inner">
<div class="container">
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</a>
<a class="brand" href="http://wbowam.github.io/"><span class=site-name>Tugqi Biz</span></a>
<div class="nav-collapse collapse">
<ul class="nav pull-right top-menu">
<li ><a href="http://wbowam.github.io">Home</a></li>
<li ><a href="http://wbowam.github.io/categories.html">Categories</a></li>
<li ><a href="http://wbowam.github.io/tags.html">Tags</a></li>
<li ><a href="http://wbowam.github.io/archives.html">Archives</a></li>
<li><form class="navbar-search" action="http://wbowam.github.io/search.html" onsubmit="return validateForm(this.elements['q'].value);"> <input type="text" class="search-query" placeholder="Search" name="q" id="tipue_search_input"></form></li>
</ul>
</div>
</div>
</div>
</div>
<div class="container-fluid">
<div class="row-fluid">
<div class="span1"></div>
<div class="span10">
<article>
<div class="row-fluid">
<header class="page_header span10">
<h1><a href="http://wbowam.github.io/git-fu-xi-gong-gu-2.html"> git 复习巩固(2) </a></h1>
</header>
</div>
<div class="row-fluid">
<div class="span10 article-content">
<h4 id="1">1. 对象名<a class="headerlink" href="#1" title="Permanent link">¶</a></h4>
<p><code>6ff87c4664981e4397625791c8ea3bbb5f2279a3</code> <br />
<em> 所有用来表示项目历史信息的文件,是通过一个40个字符的(40-digit)“对象名”来索引的.<br />
</em> 每一个“对象名”都是对“对象”内容做SHA1哈希计算得来的,(SHA1是一种密码学的哈希算法)。这样就意味着两个不同内容的对象不可能有相同的“对象名”。</p>
<h4 id="2">2. 对象<a class="headerlink" href="#2" title="Permanent link">¶</a></h4>
<ul>
<li>有四种类型的对象:"blob"、"tree"、 "commit" 和"tag" </li>
</ul>
<h4 id="3-blob">3. Blob 对象<a class="headerlink" href="#3-blob" title="Permanent link">¶</a></h4>
<p>新文件纳入到 Git 后会被五马分尸,它的内容被扔到在一个 blob 对象中,它的对象名是基于内容运算生成的一个 40个字符的 SHA1值。</p>
<p>blob 没有文件名,只有内容。 </p>
<p><img alt="blob" src="http://mednoter.com/media/files/2014/jul/29-object-blob.png" /></p>
<h4 id="4-tree">4. Tree 对象<a class="headerlink" href="#4-tree" title="Permanent link">¶</a></h4>
<p>一个 tree 对象就是一大坨指针,指向:</p>
<ul>
<li>其他 small tree(子级 tree)</li>
<li>blob
可以把 Tree 对象想象为 Linux 文件系统中的目录,记录了子目录的信息、文件信息。 </li>
</ul>
<p><img alt="tree" src="http://mednoter.com/media/files/2014/jul/29-object-tree.png" /></p>
<h4 id="5-commit">5. Commit 对象<a class="headerlink" href="#5-commit" title="Permanent link">¶</a></h4>
<p>一个 commit 对象由以下几部分组成</p>
<ul>
<li>作者</li>
<li>提交者</li>
<li>注释</li>
<li>指向一个 big tree 的指针 </li>
</ul>
<p><img alt="commit" src="http://mednoter.com/media/files/2014/jul/29-object-commit.png" /></p>
<h3 id="6-3blob-tree-commit">6. 我们已经了解了3种主要对象类型(blob, tree 和 commit), 让我们大概了解一下它们怎么组合到一起的<a class="headerlink" href="#6-3blob-tree-commit" title="Permanent link">¶</a></h3>
<p>如果我们一个小项目, 有如下的目录结构:</p>
<div class="highlight"><pre><span class="err">$</span><span class="o">></span><span class="n">tree</span>
<span class="p">.</span>
<span class="o">|--</span> <span class="n">README</span>
<span class="err">`</span><span class="o">--</span> <span class="n">lib</span>
<span class="o">|--</span> <span class="n">inc</span>
<span class="o">|</span> <span class="err">`</span><span class="o">--</span> <span class="n">tricks</span><span class="p">.</span><span class="n">rb</span>
<span class="err">`</span><span class="o">--</span> <span class="n">mylib</span><span class="p">.</span><span class="n">rb</span>
<span class="mi">2</span> <span class="n">directories</span><span class="p">,</span> <span class="mi">3</span> <span class="n">files</span>
</pre></div>
<p>如果我们把它提交(commit)到一个Git仓库中, 在Git中它们也许看起来就如下图: </p>
<p><img alt="示例" src="http://gitbook.liuhui998.com/assets/images/figure/objects-example.png" /></p>
<h5 id="_1">可以看到:<a class="headerlink" href="#_1" title="Permanent link">¶</a></h5>
<ul>
<li>每个目录都创建了 tree对象 (包括根目录), </li>
<li>每个文件都创建了一个对应的 blob对象 . </li>
<li>最后有一个 commit对象 来指向根tree对象(root of trees), </li>
<li>这样我们就可以追踪项目每一项提交内容.</li>
</ul>
<p><a href="http://gitbook.liuhui998.com/1_2.html">看到</a></p>
<aside>
<hr/>
<nav>
<ul class="articles_timeline">
<li class="previous_article">« <a href="http://wbowam.github.io/git-fu-xi-gong-gu-3.html" title="Previous: git 复习巩固(3)">git 复习巩固(3)</a></li>
<li class="next_article"><a href="http://wbowam.github.io/git-fu-xi-gong-gu-1.html" title="Next: git 复习巩固(1)">git 复习巩固(1)</a> »</li>
</ul>
</nav>
</aside>
<!-- Duoshuo Comment BEGIN -->
<div class="ds-thread" data-author-key="4433755"></div>
<script type="text/javascript">
var duoshuoQuery = {short_name:"tlbog"};
(function() {
var ds = document.createElement('script');
ds.type = 'text/javascript';ds.async = true;
ds.src = 'http://static.duoshuo.com/embed.js';
ds.charset = 'UTF-8';
(document.getElementsByTagName('head')[0]
|| document.getElementsByTagName('body')[0]).appendChild(ds);
})();
</script>
<!-- Duoshuo Comment END -->
</div>
<section>
<div class="span2" style="float:right;font-size:0.9em;">
<h4>Published</h4>
<time pubdate="pubdate" datetime="2015-03-29T00:00:00+08:00">Mar 29, 2015</time>
<h4>Category</h4>
<a class="category-link" href="/categories.html#It-ref">It</a>
<h4>Tags</h4>
<ul class="list-of-tags tags-in-article">
<li><a href="/tags.html#git-ref">git
<span>8</span>
</a></li>
</ul>
</div>
</section>
</div>
</article>
</div>
<div class="span1"></div>
</div>
</div>
</div>
<footer>
<div id="footer">
<ul class="footer-content">
<li class="elegant-power">Powered by <a href="http://getpelican.com/" title="Pelican Home Page">Pelican</a>. Theme: <a href="http://oncrashreboot.com/pelican-elegant" title="Theme Elegant Home Page">Elegant</a> by <a href="http://oncrashreboot.com" title="Talha Mansoor Home Page">Talha Mansoor</a></li>
</ul>
</div>
</footer> <script src="http://code.jquery.com/jquery.min.js"></script>
<script src="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/js/bootstrap.min.js"></script>
<script>
function validateForm(query)
{
return (query.length > 0);
}
</script>
</body>
</html>