summaryrefslogtreecommitdiffstats
path: root/gittutorial-2.html
diff options
context:
space:
mode:
authorJunio C Hamano <junio@hera.kernel.org>2008-07-06 05:20:31 +0000
committerJunio C Hamano <junio@hera.kernel.org>2008-07-06 05:20:31 +0000
commitba4b9286c25f18c7ebbb809ee5732a7810377ab6 (patch)
tree390507328a7564b65dc803683c34235700b97409 /gittutorial-2.html
parent05bf9c54a827e48b2b576488f5170a3490b5180e (diff)
downloadgit-htmldocs-ba4b9286c25f18c7ebbb809ee5732a7810377ab6.tar.gz
Autogenerated HTML docs for v1.5.6.2-212-g08b5
Diffstat (limited to 'gittutorial-2.html')
-rw-r--r--gittutorial-2.html262
1 files changed, 155 insertions, 107 deletions
diff --git a/gittutorial-2.html b/gittutorial-2.html
index c24a9fdbf..522ed1d6b 100644
--- a/gittutorial-2.html
+++ b/gittutorial-2.html
@@ -3,7 +3,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
-<meta name="generator" content="AsciiDoc 7.0.2" />
+<meta name="generator" content="AsciiDoc 8.2.5" />
<style type="text/css">
/* Debug borders */
p, li, dt, dd, div, pre, h1, h2, h3, h4, h5, h6 {
@@ -16,8 +16,13 @@ body {
margin: 1em 5% 1em 5%;
}
-a { color: blue; }
-a:visited { color: fuchsia; }
+a {
+ color: blue;
+ text-decoration: underline;
+}
+a:visited {
+ color: fuchsia;
+}
em {
font-style: italic;
@@ -39,13 +44,18 @@ h1, h2, h3, h4, h5, h6 {
line-height: 1.3;
}
-h1 {
+h1, h2, h3 {
border-bottom: 2px solid silver;
}
h2 {
- border-bottom: 2px solid silver;
padding-top: 0.5em;
}
+h3 {
+ float: left;
+}
+h3 + * {
+ clear: left;
+}
div.sectionbody {
font-family: serif;
@@ -70,7 +80,7 @@ span#author {
color: #527bbd;
font-family: sans-serif;
font-weight: bold;
- font-size: 1.2em;
+ font-size: 1.1em;
}
span#email {
}
@@ -139,6 +149,9 @@ div.sidebarblock > div.content {
padding: 0.5em;
}
+div.listingblock {
+ margin-right: 0%;
+}
div.listingblock > div.content {
border: 1px solid silver;
background: #f4f4f4;
@@ -148,9 +161,13 @@ div.listingblock > div.content {
div.quoteblock > div.content {
padding-left: 2.0em;
}
-div.quoteblock .attribution {
+
+div.attribution {
text-align: right;
}
+div.verseblock + div.attribution {
+ text-align: left;
+}
div.admonitionblock .icon {
vertical-align: top;
@@ -194,13 +211,12 @@ dd > *:first-child {
ul, ol {
list-style-position: outside;
}
-ol.olist2 {
+div.olist2 ol {
list-style-type: lower-alpha;
}
div.tableblock > table {
- border-color: #527bbd;
- border-width: 3px;
+ border: 3px solid #527bbd;
}
thead {
font-family: sans-serif;
@@ -214,6 +230,9 @@ div.hlist {
margin-top: 0.8em;
margin-bottom: 0.8em;
}
+div.hlist td {
+ padding-bottom: 5px;
+}
td.hlist1 {
vertical-align: top;
font-style: italic;
@@ -226,7 +245,33 @@ td.hlist2 {
@media print {
div#footer-badges { display: none; }
}
-include::./stylesheets/xhtml11-manpage.css[]
+
+div#toctitle {
+ color: #527bbd;
+ font-family: sans-serif;
+ font-size: 1.1em;
+ font-weight: bold;
+ margin-top: 1.0em;
+ margin-bottom: 0.1em;
+}
+
+div.toclevel1, div.toclevel2, div.toclevel3, div.toclevel4 {
+ margin-top: 0;
+ margin-bottom: 0;
+}
+div.toclevel2 {
+ margin-left: 2em;
+ font-size: 0.9em;
+}
+div.toclevel3 {
+ margin-left: 4em;
+ font-size: 0.9em;
+}
+div.toclevel4 {
+ margin-left: 6em;
+ font-size: 0.9em;
+}
+include1::./stylesheets/xhtml11-manpage.css[]
/* Workarounds for IE6's broken and incomplete CSS2. */
div.sidebar-content {
@@ -255,6 +300,9 @@ div.exampleblock-content {
border-left: 2px solid silver;
padding-left: 0.5em;
}
+
+/* IE6 sets dynamically generated links as visited. */
+div#toc a:visited { color: blue; }
</style>
<title>gittutorial-2(7)</title>
</head>
@@ -272,19 +320,19 @@ gittutorial-2(7) Manual Page
</div>
<h2>SYNOPSIS</h2>
<div class="sectionbody">
-<p>git *</p>
+<div class="para"><p>git *</p></div>
</div>
-<h2>DESCRIPTION</h2>
+<h2 id="_description">DESCRIPTION</h2>
<div class="sectionbody">
-<p>You should work through <a href="gittutorial.html">gittutorial(7)</a> before reading this tutorial.</p>
-<p>The goal of this tutorial is to introduce two fundamental pieces of
+<div class="para"><p>You should work through <a href="gittutorial.html">gittutorial(7)</a> before reading this tutorial.</p></div>
+<div class="para"><p>The goal of this tutorial is to introduce two fundamental pieces of
git's architecture--the object database and the index file--and to
provide the reader with everything necessary to understand the rest
-of the git documentation.</p>
+of the git documentation.</p></div>
</div>
-<h2>The git object database</h2>
+<h2 id="_the_git_object_database">The git object database</h2>
<div class="sectionbody">
-<p>Let's start a new project and create a small amount of history:</p>
+<div class="para"><p>Let's start a new project and create a small amount of history:</p></div>
<div class="listingblock">
<div class="content">
<pre><tt>$ mkdir test-project
@@ -300,22 +348,22 @@ $ echo 'hello world!' &gt;file.txt
$ git commit -a -m "add emphasis"
Created commit c4d59f390b9cfd4318117afde11d601c1085f241</tt></pre>
</div></div>
-<p>What are the 40 digits of hex that git responded to the commit with?</p>
-<p>We saw in part one of the tutorial that commits have names like this.
+<div class="para"><p>What are the 40 digits of hex that git responded to the commit with?</p></div>
+<div class="para"><p>We saw in part one of the tutorial that commits have names like this.
It turns out that every object in the git history is stored under
such a 40-digit hex name. That name is the SHA1 hash of the object's
contents; among other things, this ensures that git will never store
the same data twice (since identical data is given an identical SHA1
name), and that the contents of a git object will never change (since
-that would change the object's name as well).</p>
-<p>It is expected that the content of the commit object you created while
+that would change the object's name as well).</p></div>
+<div class="para"><p>It is expected that the content of the commit object you created while
following the example above generates a different SHA1 hash than
the one shown above because the commit object records the time when
-it was created and the name of the person performing the commit.</p>
-<p>We can ask git about this particular object with the <tt>cat-file</tt>
+it was created and the name of the person performing the commit.</p></div>
+<div class="para"><p>We can ask git about this particular object with the <tt>cat-file</tt>
command. Don't copy the 40 hex digits from this example but use those
from your own version. Note that you can shorten it to only a few
-characters to save yourself typing all 40 hex digits:</p>
+characters to save yourself typing all 40 hex digits:</p></div>
<div class="listingblock">
<div class="content">
<pre><tt>$ git cat-file -t 54196cc2
@@ -327,34 +375,34 @@ committer J. Bruce Fields &lt;bfields@puzzle.fieldses.org&gt; 1143414668 -0500
initial commit</tt></pre>
</div></div>
-<p>A tree can refer to one or more "blob" objects, each corresponding to
+<div class="para"><p>A tree can refer to one or more "blob" objects, each corresponding to
a file. In addition, a tree can also refer to other tree objects,
thus creating a directory hierarchy. You can examine the contents of
any tree using ls-tree (remember that a long enough initial portion
-of the SHA1 will also work):</p>
+of the SHA1 will also work):</p></div>
<div class="listingblock">
<div class="content">
<pre><tt>$ git ls-tree 92b8b694
100644 blob 3b18e512dba79e4c8300dd08aeb37f8e728b8dad file.txt</tt></pre>
</div></div>
-<p>Thus we see that this tree has one file in it. The SHA1 hash is a
-reference to that file's data:</p>
+<div class="para"><p>Thus we see that this tree has one file in it. The SHA1 hash is a
+reference to that file's data:</p></div>
<div class="listingblock">
<div class="content">
<pre><tt>$ git cat-file -t 3b18e512
blob</tt></pre>
</div></div>
-<p>A "blob" is just file data, which we can also examine with cat-file:</p>
+<div class="para"><p>A "blob" is just file data, which we can also examine with cat-file:</p></div>
<div class="listingblock">
<div class="content">
<pre><tt>$ git cat-file blob 3b18e512
hello world</tt></pre>
</div></div>
-<p>Note that this is the old file data; so the object that git named in
+<div class="para"><p>Note that this is the old file data; so the object that git named in
its response to the initial tree was a tree with a snapshot of the
-directory state that was recorded by the first commit.</p>
-<p>All of these objects are stored under their SHA1 names inside the git
-directory:</p>
+directory state that was recorded by the first commit.</p></div>
+<div class="para"><p>All of these objects are stored under their SHA1 names inside the git
+directory:</p></div>
<div class="listingblock">
<div class="content">
<pre><tt>$ find .git/objects/
@@ -374,20 +422,20 @@ directory:</p>
.git/objects/c4
.git/objects/c4/d59f390b9cfd4318117afde11d601c1085f241</tt></pre>
</div></div>
-<p>and the contents of these files is just the compressed data plus a
+<div class="para"><p>and the contents of these files is just the compressed data plus a
header identifying their length and their type. The type is either a
-blob, a tree, a commit, or a tag.</p>
-<p>The simplest commit to find is the HEAD commit, which we can find
-from .git/HEAD:</p>
+blob, a tree, a commit, or a tag.</p></div>
+<div class="para"><p>The simplest commit to find is the HEAD commit, which we can find
+from .git/HEAD:</p></div>
<div class="listingblock">
<div class="content">
<pre><tt>$ cat .git/HEAD
ref: refs/heads/master</tt></pre>
</div></div>
-<p>As you can see, this tells us which branch we're currently on, and it
+<div class="para"><p>As you can see, this tells us which branch we're currently on, and it
tells us this by naming a file under the .git directory, which itself
contains a SHA1 name referring to a commit object, which we can
-examine with cat-file:</p>
+examine with cat-file:</p></div>
<div class="listingblock">
<div class="content">
<pre><tt>$ cat .git/refs/heads/master
@@ -402,7 +450,7 @@ committer J. Bruce Fields &lt;bfields@puzzle.fieldses.org&gt; 1143418702 -0500
add emphasis</tt></pre>
</div></div>
-<p>The "tree" object here refers to the new state of the tree:</p>
+<div class="para"><p>The "tree" object here refers to the new state of the tree:</p></div>
<div class="listingblock">
<div class="content">
<pre><tt>$ git ls-tree d0492b36
@@ -410,7 +458,7 @@ add emphasis</tt></pre>
$ git cat-file blob a0423896
hello world!</tt></pre>
</div></div>
-<p>and the "parent" object refers to the previous commit:</p>
+<div class="para"><p>and the "parent" object refers to the previous commit:</p></div>
<div class="listingblock">
<div class="content">
<pre><tt>$ git cat-file commit 54196cc2
@@ -420,18 +468,18 @@ committer J. Bruce Fields &lt;bfields@puzzle.fieldses.org&gt; 1143414668 -0500
initial commit</tt></pre>
</div></div>
-<p>The tree object is the tree we examined first, and this commit is
-unusual in that it lacks any parent.</p>
-<p>Most commits have only one parent, but it is also common for a commit
+<div class="para"><p>The tree object is the tree we examined first, and this commit is
+unusual in that it lacks any parent.</p></div>
+<div class="para"><p>Most commits have only one parent, but it is also common for a commit
to have multiple parents. In that case the commit represents a
merge, with the parent references pointing to the heads of the merged
-branches.</p>
-<p>Besides blobs, trees, and commits, the only remaining type of object
+branches.</p></div>
+<div class="para"><p>Besides blobs, trees, and commits, the only remaining type of object
is a "tag", which we won't discuss here; refer to <a href="git-tag.html">git-tag(1)</a>
-for details.</p>
-<p>So now we know how git uses the object database to represent a
-project's history:</p>
-<ul>
+for details.</p></div>
+<div class="para"><p>So now we know how git uses the object database to represent a
+project's history:</p></div>
+<div class="ilist"><ul>
<li>
<p>
"commit" objects refer to "tree" objects representing the
@@ -463,31 +511,31 @@ References to commit objects at the head of each branch are
The name of the current branch is stored in .git/HEAD.
</p>
</li>
-</ul>
-<p>Note, by the way, that lots of commands take a tree as an argument.
+</ul></div>
+<div class="para"><p>Note, by the way, that lots of commands take a tree as an argument.
But as we can see above, a tree can be referred to in many different
ways--by the SHA1 name for that tree, by the name of a commit that
refers to the tree, by the name of a branch whose head refers to that
-tree, etc.--and most such commands can accept any of these names.</p>
-<p>In command synopses, the word "tree-ish" is sometimes used to
-designate such an argument.</p>
+tree, etc.--and most such commands can accept any of these names.</p></div>
+<div class="para"><p>In command synopses, the word "tree-ish" is sometimes used to
+designate such an argument.</p></div>
</div>
-<h2>The index file</h2>
+<h2 id="_the_index_file">The index file</h2>
<div class="sectionbody">
-<p>The primary tool we've been using to create commits is <tt>git-commit
+<div class="para"><p>The primary tool we've been using to create commits is <tt>git-commit
-a</tt>, which creates a commit including every change you've made to
your working tree. But what if you want to commit changes only to
-certain files? Or only certain changes to certain files?</p>
-<p>If we look at the way commits are created under the cover, we'll see
-that there are more flexible ways creating commits.</p>
-<p>Continuing with our test-project, let's modify file.txt again:</p>
+certain files? Or only certain changes to certain files?</p></div>
+<div class="para"><p>If we look at the way commits are created under the cover, we'll see
+that there are more flexible ways creating commits.</p></div>
+<div class="para"><p>Continuing with our test-project, let's modify file.txt again:</p></div>
<div class="listingblock">
<div class="content">
<pre><tt>$ echo "hello world, again" &gt;&gt;file.txt</tt></pre>
</div></div>
-<p>but this time instead of immediately making the commit, let's take an
+<div class="para"><p>but this time instead of immediately making the commit, let's take an
intermediate step, and ask for diffs along the way to keep track of
-what's happening:</p>
+what's happening:</p></div>
<div class="listingblock">
<div class="content">
<pre><tt>$ git diff
@@ -499,8 +547,8 @@ what's happening:</p>
$ git add file.txt
$ git diff</tt></pre>
</div></div>
-<p>The last diff is empty, but no new commits have been made, and the
-head still doesn't contain the new line:</p>
+<div class="para"><p>The last diff is empty, but no new commits have been made, and the
+head still doesn't contain the new line:</p></div>
<div class="listingblock">
<div class="content">
<pre><tt>$ git diff HEAD
@@ -512,10 +560,10 @@ index a042389..513feba 100644
hello world!
+hello world, again</tt></pre>
</div></div>
-<p>So <tt>git-diff</tt> is comparing against something other than the head.
+<div class="para"><p>So <em>git-diff</em> is comparing against something other than the head.
The thing that it's comparing against is actually the index file,
which is stored in .git/index in a binary format, but whose contents
-we can examine with ls-files:</p>
+we can examine with ls-files:</p></div>
<div class="listingblock">
<div class="content">
<pre><tt>$ git ls-files --stage
@@ -526,10 +574,10 @@ $ git cat-file blob 513feba2
hello world!
hello world, again</tt></pre>
</div></div>
-<p>So what our <tt>git-add</tt> did was store a new blob and then put
+<div class="para"><p>So what our <em>git-add</em> did was store a new blob and then put
a reference to it in the index file. If we modify the file again,
-we'll see that the new modifications are reflected in the <tt>git-diff</tt>
-output:</p>
+we'll see that the new modifications are reflected in the <em>git-diff</em>
+output:</p></div>
<div class="listingblock">
<div class="content">
<pre><tt>$ echo 'again?' &gt;&gt;file.txt
@@ -542,9 +590,9 @@ index 513feba..ba3da7b 100644
hello world, again
+again?</tt></pre>
</div></div>
-<p>With the right arguments, <tt>git-diff</tt> can also show us the difference
+<div class="para"><p>With the right arguments, <em>git-diff</em> can also show us the difference
between the working directory and the last commit, or between the
-index and the last commit:</p>
+index and the last commit:</p></div>
<div class="listingblock">
<div class="content">
<pre><tt>$ git diff HEAD
@@ -565,10 +613,10 @@ index a042389..513feba 100644
hello world!
+hello world, again</tt></pre>
</div></div>
-<p>At any time, we can create a new commit using <tt>git-commit</tt> (without
+<div class="para"><p>At any time, we can create a new commit using <em>git-commit</em> (without
the "-a" option), and verify that the state committed only includes the
changes stored in the index file, not the additional change that is
-still only in our working tree:</p>
+still only in our working tree:</p></div>
<div class="listingblock">
<div class="content">
<pre><tt>$ git commit -m "repeat"
@@ -582,32 +630,32 @@ index 513feba..ba3da7b 100644
hello world, again
+again?</tt></pre>
</div></div>
-<p>So by default <tt>git-commit</tt> uses the index to create the commit, not
+<div class="para"><p>So by default <em>git-commit</em> uses the index to create the commit, not
the working tree; the "-a" option to commit tells it to first update
-the index with all changes in the working tree.</p>
-<p>Finally, it's worth looking at the effect of <tt>git-add</tt> on the index
-file:</p>
+the index with all changes in the working tree.</p></div>
+<div class="para"><p>Finally, it's worth looking at the effect of <em>git-add</em> on the index
+file:</p></div>
<div class="listingblock">
<div class="content">
<pre><tt>$ echo "goodbye, world" &gt;closing.txt
$ git add closing.txt</tt></pre>
</div></div>
-<p>The effect of the <tt>git-add</tt> was to add one entry to the index file:</p>
+<div class="para"><p>The effect of the <em>git-add</em> was to add one entry to the index file:</p></div>
<div class="listingblock">
<div class="content">
<pre><tt>$ git ls-files --stage
100644 8b9743b20d4b15be3955fc8d5cd2b09cd2336138 0 closing.txt
100644 513feba2e53ebbd2532419ded848ba19de88ba00 0 file.txt</tt></pre>
</div></div>
-<p>And, as you can see with cat-file, this new entry refers to the
-current contents of the file:</p>
+<div class="para"><p>And, as you can see with cat-file, this new entry refers to the
+current contents of the file:</p></div>
<div class="listingblock">
<div class="content">
<pre><tt>$ git cat-file blob 8b9743b2
goodbye, world</tt></pre>
</div></div>
-<p>The "status" command is a useful way to get a quick summary of the
-situation:</p>
+<div class="para"><p>The "status" command is a useful way to get a quick summary of the
+situation:</p></div>
<div class="listingblock">
<div class="content">
<pre><tt>$ git status
@@ -623,54 +671,54 @@ situation:</p>
# modified: file.txt
#</tt></pre>
</div></div>
-<p>Since the current state of closing.txt is cached in the index file,
+<div class="para"><p>Since the current state of closing.txt is cached in the index file,
it is listed as "Changes to be committed". Since file.txt has
changes in the working directory that aren't reflected in the index,
it is marked "changed but not updated". At this point, running "git
commit" would create a commit that added closing.txt (with its new
-contents), but that didn't modify file.txt.</p>
-<p>Also, note that a bare <tt>git diff</tt> shows the changes to file.txt, but
+contents), but that didn't modify file.txt.</p></div>
+<div class="para"><p>Also, note that a bare <tt>git diff</tt> shows the changes to file.txt, but
not the addition of closing.txt, because the version of closing.txt
-in the index file is identical to the one in the working directory.</p>
-<p>In addition to being the staging area for new commits, the index file
+in the index file is identical to the one in the working directory.</p></div>
+<div class="para"><p>In addition to being the staging area for new commits, the index file
is also populated from the object database when checking out a
branch, and is used to hold the trees involved in a merge operation.
See <a href="gitcore-tutorial.html">gitcore-tutorial(7)</a> and the relevant man
-pages for details.</p>
+pages for details.</p></div>
</div>
-<h2>What next?</h2>
+<h2 id="_what_next">What next?</h2>
<div class="sectionbody">
-<p>At this point you should know everything necessary to read the man
+<div class="para"><p>At this point you should know everything necessary to read the man
pages for any of the git commands; one good place to start would be
with the commands mentioned in <a href="everyday.html">Everyday git</a>. You
-should be able to find any unknown jargon in <a href="gitglossary.html">gitglossary(7)</a>.</p>
-<p>The <a href="user-manual.html">Git User's Manual</a> provides a more
-comprehensive introduction to git.</p>
-<p><a href="gitcvs-migration.html">gitcvs-migration(7)</a> explains how to
+should be able to find any unknown jargon in <a href="gitglossary.html">gitglossary(7)</a>.</p></div>
+<div class="para"><p>The <a href="user-manual.html">Git User's Manual</a> provides a more
+comprehensive introduction to git.</p></div>
+<div class="para"><p><a href="gitcvs-migration.html">gitcvs-migration(7)</a> explains how to
import a CVS repository into git, and shows how to use git in a
-CVS-like way.</p>
-<p>For some interesting examples of git use, see the
-<a href="howto-index.html">howtos</a>.</p>
-<p>For git developers, <a href="gitcore-tutorial.html">gitcore-tutorial(7)</a> goes
+CVS-like way.</p></div>
+<div class="para"><p>For some interesting examples of git use, see the
+<a href="howto-index.html">howtos</a>.</p></div>
+<div class="para"><p>For git developers, <a href="gitcore-tutorial.html">gitcore-tutorial(7)</a> goes
into detail on the lower-level git mechanisms involved in, for
-example, creating a new commit.</p>
+example, creating a new commit.</p></div>
</div>
-<h2>SEE ALSO</h2>
+<h2 id="_see_also">SEE ALSO</h2>
<div class="sectionbody">
-<p><a href="gittutorial.html">gittutorial(7)</a>,
+<div class="para"><p><a href="gittutorial.html">gittutorial(7)</a>,
<a href="gitcvs-migration.html">gitcvs-migration(7)</a>,
<a href="gitcore-tutorial.html">gitcore-tutorial(7)</a>,
<a href="gitglossary.html">gitglossary(7)</a>,
<a href="everyday.html">Everyday git</a>,
-<a href="user-manual.html">The Git User's Manual</a></p>
+<a href="user-manual.html">The Git User's Manual</a></p></div>
</div>
-<h2>GIT</h2>
+<h2 id="_git">GIT</h2>
<div class="sectionbody">
-<p>Part of the <a href="git.html">git(1)</a> suite.</p>
+<div class="para"><p>Part of the <a href="git.html">git(1)</a> suite.</p></div>
</div>
<div id="footer">
<div id="footer-text">
-Last updated 02-Jul-2008 03:02:11 UTC
+Last updated 2008-07-06 05:17:11 UTC
</div>
</div>
</body>