Autogenerated HTML docs for v1.7.6-472-g4bfe7
[git/jnareb-git.git] / gittutorial-2.html
blobc5590686f7fd4d6b55718ed2d03a7989c4c4d67d
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
2 "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
4 <head>
5 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
6 <meta name="generator" content="AsciiDoc 8.4.5" />
7 <title>gittutorial-2(7)</title>
8 <style type="text/css">
9 /* Debug borders */
10 p, li, dt, dd, div, pre, h1, h2, h3, h4, h5, h6 {
12 border: 1px solid red;
16 body {
17 margin: 1em 5% 1em 5%;
20 a {
21 color: blue;
22 text-decoration: underline;
24 a:visited {
25 color: fuchsia;
28 em {
29 font-style: italic;
30 color: navy;
33 strong {
34 font-weight: bold;
35 color: #083194;
38 tt {
39 color: navy;
42 h1, h2, h3, h4, h5, h6 {
43 color: #527bbd;
44 font-family: sans-serif;
45 margin-top: 1.2em;
46 margin-bottom: 0.5em;
47 line-height: 1.3;
50 h1, h2, h3 {
51 border-bottom: 2px solid silver;
53 h2 {
54 padding-top: 0.5em;
56 h3 {
57 float: left;
59 h3 + * {
60 clear: left;
63 div.sectionbody {
64 font-family: serif;
65 margin-left: 0;
68 hr {
69 border: 1px solid silver;
72 p {
73 margin-top: 0.5em;
74 margin-bottom: 0.5em;
77 ul, ol, li > p {
78 margin-top: 0;
81 pre {
82 padding: 0;
83 margin: 0;
86 span#author {
87 color: #527bbd;
88 font-family: sans-serif;
89 font-weight: bold;
90 font-size: 1.1em;
92 span#email {
94 span#revnumber, span#revdate, span#revremark {
95 font-family: sans-serif;
98 div#footer {
99 font-family: sans-serif;
100 font-size: small;
101 border-top: 2px solid silver;
102 padding-top: 0.5em;
103 margin-top: 4.0em;
105 div#footer-text {
106 float: left;
107 padding-bottom: 0.5em;
109 div#footer-badges {
110 float: right;
111 padding-bottom: 0.5em;
114 div#preamble {
115 margin-top: 1.5em;
116 margin-bottom: 1.5em;
118 div.tableblock, div.imageblock, div.exampleblock, div.verseblock,
119 div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock,
120 div.admonitionblock {
121 margin-top: 1.5em;
122 margin-bottom: 1.5em;
124 div.admonitionblock {
125 margin-top: 2.5em;
126 margin-bottom: 2.5em;
129 div.content { /* Block element content. */
130 padding: 0;
133 /* Block element titles. */
134 div.title, caption.title {
135 color: #527bbd;
136 font-family: sans-serif;
137 font-weight: bold;
138 text-align: left;
139 margin-top: 1.0em;
140 margin-bottom: 0.5em;
142 div.title + * {
143 margin-top: 0;
146 td div.title:first-child {
147 margin-top: 0.0em;
149 div.content div.title:first-child {
150 margin-top: 0.0em;
152 div.content + div.title {
153 margin-top: 0.0em;
156 div.sidebarblock > div.content {
157 background: #ffffee;
158 border: 1px solid silver;
159 padding: 0.5em;
162 div.listingblock > div.content {
163 border: 1px solid silver;
164 background: #f4f4f4;
165 padding: 0.5em;
168 div.quoteblock {
169 padding-left: 2.0em;
170 margin-right: 10%;
172 div.quoteblock > div.attribution {
173 padding-top: 0.5em;
174 text-align: right;
177 div.verseblock {
178 padding-left: 2.0em;
179 margin-right: 10%;
181 div.verseblock > div.content {
182 white-space: pre;
184 div.verseblock > div.attribution {
185 padding-top: 0.75em;
186 text-align: left;
188 /* DEPRECATED: Pre version 8.2.7 verse style literal block. */
189 div.verseblock + div.attribution {
190 text-align: left;
193 div.admonitionblock .icon {
194 vertical-align: top;
195 font-size: 1.1em;
196 font-weight: bold;
197 text-decoration: underline;
198 color: #527bbd;
199 padding-right: 0.5em;
201 div.admonitionblock td.content {
202 padding-left: 0.5em;
203 border-left: 2px solid silver;
206 div.exampleblock > div.content {
207 border-left: 2px solid silver;
208 padding: 0.5em;
211 div.imageblock div.content { padding-left: 0; }
212 span.image img { border-style: none; }
213 a.image:visited { color: white; }
215 dl {
216 margin-top: 0.8em;
217 margin-bottom: 0.8em;
219 dt {
220 margin-top: 0.5em;
221 margin-bottom: 0;
222 font-style: normal;
223 color: navy;
225 dd > *:first-child {
226 margin-top: 0.1em;
229 ul, ol {
230 list-style-position: outside;
232 ol.arabic {
233 list-style-type: decimal;
235 ol.loweralpha {
236 list-style-type: lower-alpha;
238 ol.upperalpha {
239 list-style-type: upper-alpha;
241 ol.lowerroman {
242 list-style-type: lower-roman;
244 ol.upperroman {
245 list-style-type: upper-roman;
248 div.compact ul, div.compact ol,
249 div.compact p, div.compact p,
250 div.compact div, div.compact div {
251 margin-top: 0.1em;
252 margin-bottom: 0.1em;
255 div.tableblock > table {
256 border: 3px solid #527bbd;
258 thead {
259 font-family: sans-serif;
260 font-weight: bold;
262 tfoot {
263 font-weight: bold;
265 td > div.verse {
266 white-space: pre;
268 p.table {
269 margin-top: 0;
271 /* Because the table frame attribute is overriden by CSS in most browsers. */
272 div.tableblock > table[frame="void"] {
273 border-style: none;
275 div.tableblock > table[frame="hsides"] {
276 border-left-style: none;
277 border-right-style: none;
279 div.tableblock > table[frame="vsides"] {
280 border-top-style: none;
281 border-bottom-style: none;
285 div.hdlist {
286 margin-top: 0.8em;
287 margin-bottom: 0.8em;
289 div.hdlist tr {
290 padding-bottom: 15px;
292 dt.hdlist1.strong, td.hdlist1.strong {
293 font-weight: bold;
295 td.hdlist1 {
296 vertical-align: top;
297 font-style: normal;
298 padding-right: 0.8em;
299 color: navy;
301 td.hdlist2 {
302 vertical-align: top;
304 div.hdlist.compact tr {
305 margin: 0;
306 padding-bottom: 0;
309 .comment {
310 background: yellow;
313 @media print {
314 div#footer-badges { display: none; }
317 div#toctitle {
318 color: #527bbd;
319 font-family: sans-serif;
320 font-size: 1.1em;
321 font-weight: bold;
322 margin-top: 1.0em;
323 margin-bottom: 0.1em;
326 div.toclevel1, div.toclevel2, div.toclevel3, div.toclevel4 {
327 margin-top: 0;
328 margin-bottom: 0;
330 div.toclevel2 {
331 margin-left: 2em;
332 font-size: 0.9em;
334 div.toclevel3 {
335 margin-left: 4em;
336 font-size: 0.9em;
338 div.toclevel4 {
339 margin-left: 6em;
340 font-size: 0.9em;
342 /* Overrides for manpage documents */
343 h1 {
344 padding-top: 0.5em;
345 padding-bottom: 0.5em;
346 border-top: 2px solid silver;
347 border-bottom: 2px solid silver;
349 h2 {
350 border-style: none;
352 div.sectionbody {
353 margin-left: 5%;
356 @media print {
357 div#toc { display: none; }
360 /* Workarounds for IE6's broken and incomplete CSS2. */
362 div.sidebar-content {
363 background: #ffffee;
364 border: 1px solid silver;
365 padding: 0.5em;
367 div.sidebar-title, div.image-title {
368 color: #527bbd;
369 font-family: sans-serif;
370 font-weight: bold;
371 margin-top: 0.0em;
372 margin-bottom: 0.5em;
375 div.listingblock div.content {
376 border: 1px solid silver;
377 background: #f4f4f4;
378 padding: 0.5em;
381 div.quoteblock-attribution {
382 padding-top: 0.5em;
383 text-align: right;
386 div.verseblock-content {
387 white-space: pre;
389 div.verseblock-attribution {
390 padding-top: 0.75em;
391 text-align: left;
394 div.exampleblock-content {
395 border-left: 2px solid silver;
396 padding-left: 0.5em;
399 /* IE6 sets dynamically generated links as visited. */
400 div#toc a:visited { color: blue; }
401 </style>
402 </head>
403 <body>
404 <div id="header">
405 <h1>
406 gittutorial-2(7) Manual Page
407 </h1>
408 <h2>NAME</h2>
409 <div class="sectionbody">
410 <p>gittutorial-2 -
411 A tutorial introduction to git: part two
412 </p>
413 </div>
414 </div>
415 <h2 id="_synopsis">SYNOPSIS</h2>
416 <div class="sectionbody">
417 <div class="verseblock">
418 <div class="verseblock-content">git *</div>
419 <div class="verseblock-attribution">
420 </div></div>
421 </div>
422 <h2 id="_description">DESCRIPTION</h2>
423 <div class="sectionbody">
424 <div class="paragraph"><p>You should work through <a href="gittutorial.html">gittutorial(7)</a> before reading this tutorial.</p></div>
425 <div class="paragraph"><p>The goal of this tutorial is to introduce two fundamental pieces of
426 git&#8217;s architecture&#8212;the object database and the index file&#8212;and to
427 provide the reader with everything necessary to understand the rest
428 of the git documentation.</p></div>
429 </div>
430 <h2 id="_the_git_object_database">The git object database</h2>
431 <div class="sectionbody">
432 <div class="paragraph"><p>Let&#8217;s start a new project and create a small amount of history:</p></div>
433 <div class="listingblock">
434 <div class="content">
435 <pre><tt>$ mkdir test-project
436 $ cd test-project
437 $ git init
438 Initialized empty Git repository in .git/
439 $ echo 'hello world' &gt; file.txt
440 $ git add .
441 $ git commit -a -m "initial commit"
442 [master (root-commit) 54196cc] initial commit
443 1 files changed, 1 insertions(+), 0 deletions(-)
444 create mode 100644 file.txt
445 $ echo 'hello world!' &gt;file.txt
446 $ git commit -a -m "add emphasis"
447 [master c4d59f3] add emphasis
448 1 files changed, 1 insertions(+), 1 deletions(-)</tt></pre>
449 </div></div>
450 <div class="paragraph"><p>What are the 7 digits of hex that git responded to the commit with?</p></div>
451 <div class="paragraph"><p>We saw in part one of the tutorial that commits have names like this.
452 It turns out that every object in the git history is stored under
453 a 40-digit hex name. That name is the SHA1 hash of the object&#8217;s
454 contents; among other things, this ensures that git will never store
455 the same data twice (since identical data is given an identical SHA1
456 name), and that the contents of a git object will never change (since
457 that would change the object&#8217;s name as well). The 7 char hex strings
458 here are simply the abbreviation of such 40 character long strings.
459 Abbreviations can be used everywhere where the 40 character strings
460 can be used, so long as they are unambiguous.</p></div>
461 <div class="paragraph"><p>It is expected that the content of the commit object you created while
462 following the example above generates a different SHA1 hash than
463 the one shown above because the commit object records the time when
464 it was created and the name of the person performing the commit.</p></div>
465 <div class="paragraph"><p>We can ask git about this particular object with the <tt>cat-file</tt>
466 command. Don&#8217;t copy the 40 hex digits from this example but use those
467 from your own version. Note that you can shorten it to only a few
468 characters to save yourself typing all 40 hex digits:</p></div>
469 <div class="listingblock">
470 <div class="content">
471 <pre><tt>$ git cat-file -t 54196cc2
472 commit
473 $ git cat-file commit 54196cc2
474 tree 92b8b694ffb1675e5975148e1121810081dbdffe
475 author J. Bruce Fields &lt;bfields@puzzle.fieldses.org&gt; 1143414668 -0500
476 committer J. Bruce Fields &lt;bfields@puzzle.fieldses.org&gt; 1143414668 -0500
478 initial commit</tt></pre>
479 </div></div>
480 <div class="paragraph"><p>A tree can refer to one or more "blob" objects, each corresponding to
481 a file. In addition, a tree can also refer to other tree objects,
482 thus creating a directory hierarchy. You can examine the contents of
483 any tree using ls-tree (remember that a long enough initial portion
484 of the SHA1 will also work):</p></div>
485 <div class="listingblock">
486 <div class="content">
487 <pre><tt>$ git ls-tree 92b8b694
488 100644 blob 3b18e512dba79e4c8300dd08aeb37f8e728b8dad file.txt</tt></pre>
489 </div></div>
490 <div class="paragraph"><p>Thus we see that this tree has one file in it. The SHA1 hash is a
491 reference to that file&#8217;s data:</p></div>
492 <div class="listingblock">
493 <div class="content">
494 <pre><tt>$ git cat-file -t 3b18e512
495 blob</tt></pre>
496 </div></div>
497 <div class="paragraph"><p>A "blob" is just file data, which we can also examine with cat-file:</p></div>
498 <div class="listingblock">
499 <div class="content">
500 <pre><tt>$ git cat-file blob 3b18e512
501 hello world</tt></pre>
502 </div></div>
503 <div class="paragraph"><p>Note that this is the old file data; so the object that git named in
504 its response to the initial tree was a tree with a snapshot of the
505 directory state that was recorded by the first commit.</p></div>
506 <div class="paragraph"><p>All of these objects are stored under their SHA1 names inside the git
507 directory:</p></div>
508 <div class="listingblock">
509 <div class="content">
510 <pre><tt>$ find .git/objects/
511 .git/objects/
512 .git/objects/pack
513 .git/objects/info
514 .git/objects/3b
515 .git/objects/3b/18e512dba79e4c8300dd08aeb37f8e728b8dad
516 .git/objects/92
517 .git/objects/92/b8b694ffb1675e5975148e1121810081dbdffe
518 .git/objects/54
519 .git/objects/54/196cc2703dc165cbd373a65a4dcf22d50ae7f7
520 .git/objects/a0
521 .git/objects/a0/423896973644771497bdc03eb99d5281615b51
522 .git/objects/d0
523 .git/objects/d0/492b368b66bdabf2ac1fd8c92b39d3db916e59
524 .git/objects/c4
525 .git/objects/c4/d59f390b9cfd4318117afde11d601c1085f241</tt></pre>
526 </div></div>
527 <div class="paragraph"><p>and the contents of these files is just the compressed data plus a
528 header identifying their length and their type. The type is either a
529 blob, a tree, a commit, or a tag.</p></div>
530 <div class="paragraph"><p>The simplest commit to find is the HEAD commit, which we can find
531 from .git/HEAD:</p></div>
532 <div class="listingblock">
533 <div class="content">
534 <pre><tt>$ cat .git/HEAD
535 ref: refs/heads/master</tt></pre>
536 </div></div>
537 <div class="paragraph"><p>As you can see, this tells us which branch we&#8217;re currently on, and it
538 tells us this by naming a file under the .git directory, which itself
539 contains a SHA1 name referring to a commit object, which we can
540 examine with cat-file:</p></div>
541 <div class="listingblock">
542 <div class="content">
543 <pre><tt>$ cat .git/refs/heads/master
544 c4d59f390b9cfd4318117afde11d601c1085f241
545 $ git cat-file -t c4d59f39
546 commit
547 $ git cat-file commit c4d59f39
548 tree d0492b368b66bdabf2ac1fd8c92b39d3db916e59
549 parent 54196cc2703dc165cbd373a65a4dcf22d50ae7f7
550 author J. Bruce Fields &lt;bfields@puzzle.fieldses.org&gt; 1143418702 -0500
551 committer J. Bruce Fields &lt;bfields@puzzle.fieldses.org&gt; 1143418702 -0500
553 add emphasis</tt></pre>
554 </div></div>
555 <div class="paragraph"><p>The "tree" object here refers to the new state of the tree:</p></div>
556 <div class="listingblock">
557 <div class="content">
558 <pre><tt>$ git ls-tree d0492b36
559 100644 blob a0423896973644771497bdc03eb99d5281615b51 file.txt
560 $ git cat-file blob a0423896
561 hello world!</tt></pre>
562 </div></div>
563 <div class="paragraph"><p>and the "parent" object refers to the previous commit:</p></div>
564 <div class="listingblock">
565 <div class="content">
566 <pre><tt>$ git cat-file commit 54196cc2
567 tree 92b8b694ffb1675e5975148e1121810081dbdffe
568 author J. Bruce Fields &lt;bfields@puzzle.fieldses.org&gt; 1143414668 -0500
569 committer J. Bruce Fields &lt;bfields@puzzle.fieldses.org&gt; 1143414668 -0500
571 initial commit</tt></pre>
572 </div></div>
573 <div class="paragraph"><p>The tree object is the tree we examined first, and this commit is
574 unusual in that it lacks any parent.</p></div>
575 <div class="paragraph"><p>Most commits have only one parent, but it is also common for a commit
576 to have multiple parents. In that case the commit represents a
577 merge, with the parent references pointing to the heads of the merged
578 branches.</p></div>
579 <div class="paragraph"><p>Besides blobs, trees, and commits, the only remaining type of object
580 is a "tag", which we won&#8217;t discuss here; refer to <a href="git-tag.html">git-tag(1)</a>
581 for details.</p></div>
582 <div class="paragraph"><p>So now we know how git uses the object database to represent a
583 project&#8217;s history:</p></div>
584 <div class="ulist"><ul>
585 <li>
587 "commit" objects refer to "tree" objects representing the
588 snapshot of a directory tree at a particular point in the
589 history, and refer to "parent" commits to show how they&#8217;re
590 connected into the project history.
591 </p>
592 </li>
593 <li>
595 "tree" objects represent the state of a single directory,
596 associating directory names to "blob" objects containing file
597 data and "tree" objects containing subdirectory information.
598 </p>
599 </li>
600 <li>
602 "blob" objects contain file data without any other structure.
603 </p>
604 </li>
605 <li>
607 References to commit objects at the head of each branch are
608 stored in files under .git/refs/heads/.
609 </p>
610 </li>
611 <li>
613 The name of the current branch is stored in .git/HEAD.
614 </p>
615 </li>
616 </ul></div>
617 <div class="paragraph"><p>Note, by the way, that lots of commands take a tree as an argument.
618 But as we can see above, a tree can be referred to in many different
619 ways&#8212;by the SHA1 name for that tree, by the name of a commit that
620 refers to the tree, by the name of a branch whose head refers to that
621 tree, etc.--and most such commands can accept any of these names.</p></div>
622 <div class="paragraph"><p>In command synopses, the word "tree-ish" is sometimes used to
623 designate such an argument.</p></div>
624 </div>
625 <h2 id="_the_index_file">The index file</h2>
626 <div class="sectionbody">
627 <div class="paragraph"><p>The primary tool we&#8217;ve been using to create commits is <tt>git-commit
628 -a</tt>, which creates a commit including every change you&#8217;ve made to
629 your working tree. But what if you want to commit changes only to
630 certain files? Or only certain changes to certain files?</p></div>
631 <div class="paragraph"><p>If we look at the way commits are created under the cover, we&#8217;ll see
632 that there are more flexible ways creating commits.</p></div>
633 <div class="paragraph"><p>Continuing with our test-project, let&#8217;s modify file.txt again:</p></div>
634 <div class="listingblock">
635 <div class="content">
636 <pre><tt>$ echo "hello world, again" &gt;&gt;file.txt</tt></pre>
637 </div></div>
638 <div class="paragraph"><p>but this time instead of immediately making the commit, let&#8217;s take an
639 intermediate step, and ask for diffs along the way to keep track of
640 what&#8217;s happening:</p></div>
641 <div class="listingblock">
642 <div class="content">
643 <pre><tt>$ git diff
644 --- a/file.txt
645 +++ b/file.txt
646 @@ -1 +1,2 @@
647 hello world!
648 +hello world, again
649 $ git add file.txt
650 $ git diff</tt></pre>
651 </div></div>
652 <div class="paragraph"><p>The last diff is empty, but no new commits have been made, and the
653 head still doesn&#8217;t contain the new line:</p></div>
654 <div class="listingblock">
655 <div class="content">
656 <pre><tt>$ git diff HEAD
657 diff --git a/file.txt b/file.txt
658 index a042389..513feba 100644
659 --- a/file.txt
660 +++ b/file.txt
661 @@ -1 +1,2 @@
662 hello world!
663 +hello world, again</tt></pre>
664 </div></div>
665 <div class="paragraph"><p>So <em>git diff</em> is comparing against something other than the head.
666 The thing that it&#8217;s comparing against is actually the index file,
667 which is stored in .git/index in a binary format, but whose contents
668 we can examine with ls-files:</p></div>
669 <div class="listingblock">
670 <div class="content">
671 <pre><tt>$ git ls-files --stage
672 100644 513feba2e53ebbd2532419ded848ba19de88ba00 0 file.txt
673 $ git cat-file -t 513feba2
674 blob
675 $ git cat-file blob 513feba2
676 hello world!
677 hello world, again</tt></pre>
678 </div></div>
679 <div class="paragraph"><p>So what our <em>git add</em> did was store a new blob and then put
680 a reference to it in the index file. If we modify the file again,
681 we&#8217;ll see that the new modifications are reflected in the <em>git diff</em>
682 output:</p></div>
683 <div class="listingblock">
684 <div class="content">
685 <pre><tt>$ echo 'again?' &gt;&gt;file.txt
686 $ git diff
687 index 513feba..ba3da7b 100644
688 --- a/file.txt
689 +++ b/file.txt
690 @@ -1,2 +1,3 @@
691 hello world!
692 hello world, again
693 +again?</tt></pre>
694 </div></div>
695 <div class="paragraph"><p>With the right arguments, <em>git diff</em> can also show us the difference
696 between the working directory and the last commit, or between the
697 index and the last commit:</p></div>
698 <div class="listingblock">
699 <div class="content">
700 <pre><tt>$ git diff HEAD
701 diff --git a/file.txt b/file.txt
702 index a042389..ba3da7b 100644
703 --- a/file.txt
704 +++ b/file.txt
705 @@ -1 +1,3 @@
706 hello world!
707 +hello world, again
708 +again?
709 $ git diff --cached
710 diff --git a/file.txt b/file.txt
711 index a042389..513feba 100644
712 --- a/file.txt
713 +++ b/file.txt
714 @@ -1 +1,2 @@
715 hello world!
716 +hello world, again</tt></pre>
717 </div></div>
718 <div class="paragraph"><p>At any time, we can create a new commit using <em>git commit</em> (without
719 the "-a" option), and verify that the state committed only includes the
720 changes stored in the index file, not the additional change that is
721 still only in our working tree:</p></div>
722 <div class="listingblock">
723 <div class="content">
724 <pre><tt>$ git commit -m "repeat"
725 $ git diff HEAD
726 diff --git a/file.txt b/file.txt
727 index 513feba..ba3da7b 100644
728 --- a/file.txt
729 +++ b/file.txt
730 @@ -1,2 +1,3 @@
731 hello world!
732 hello world, again
733 +again?</tt></pre>
734 </div></div>
735 <div class="paragraph"><p>So by default <em>git commit</em> uses the index to create the commit, not
736 the working tree; the "-a" option to commit tells it to first update
737 the index with all changes in the working tree.</p></div>
738 <div class="paragraph"><p>Finally, it&#8217;s worth looking at the effect of <em>git add</em> on the index
739 file:</p></div>
740 <div class="listingblock">
741 <div class="content">
742 <pre><tt>$ echo "goodbye, world" &gt;closing.txt
743 $ git add closing.txt</tt></pre>
744 </div></div>
745 <div class="paragraph"><p>The effect of the <em>git add</em> was to add one entry to the index file:</p></div>
746 <div class="listingblock">
747 <div class="content">
748 <pre><tt>$ git ls-files --stage
749 100644 8b9743b20d4b15be3955fc8d5cd2b09cd2336138 0 closing.txt
750 100644 513feba2e53ebbd2532419ded848ba19de88ba00 0 file.txt</tt></pre>
751 </div></div>
752 <div class="paragraph"><p>And, as you can see with cat-file, this new entry refers to the
753 current contents of the file:</p></div>
754 <div class="listingblock">
755 <div class="content">
756 <pre><tt>$ git cat-file blob 8b9743b2
757 goodbye, world</tt></pre>
758 </div></div>
759 <div class="paragraph"><p>The "status" command is a useful way to get a quick summary of the
760 situation:</p></div>
761 <div class="listingblock">
762 <div class="content">
763 <pre><tt>$ git status
764 # On branch master
765 # Changes to be committed:
766 # (use "git reset HEAD &lt;file&gt;..." to unstage)
768 # new file: closing.txt
770 # Changes not staged for commit:
771 # (use "git add &lt;file&gt;..." to update what will be committed)
773 # modified: file.txt
774 #</tt></pre>
775 </div></div>
776 <div class="paragraph"><p>Since the current state of closing.txt is cached in the index file,
777 it is listed as "Changes to be committed". Since file.txt has
778 changes in the working directory that aren&#8217;t reflected in the index,
779 it is marked "changed but not updated". At this point, running "git
780 commit" would create a commit that added closing.txt (with its new
781 contents), but that didn&#8217;t modify file.txt.</p></div>
782 <div class="paragraph"><p>Also, note that a bare <tt>git diff</tt> shows the changes to file.txt, but
783 not the addition of closing.txt, because the version of closing.txt
784 in the index file is identical to the one in the working directory.</p></div>
785 <div class="paragraph"><p>In addition to being the staging area for new commits, the index file
786 is also populated from the object database when checking out a
787 branch, and is used to hold the trees involved in a merge operation.
788 See <a href="gitcore-tutorial.html">gitcore-tutorial(7)</a> and the relevant man
789 pages for details.</p></div>
790 </div>
791 <h2 id="_what_next">What next?</h2>
792 <div class="sectionbody">
793 <div class="paragraph"><p>At this point you should know everything necessary to read the man
794 pages for any of the git commands; one good place to start would be
795 with the commands mentioned in <a href="everyday.html">Everyday git</a>. You
796 should be able to find any unknown jargon in <a href="gitglossary.html">gitglossary(7)</a>.</p></div>
797 <div class="paragraph"><p>The <a href="user-manual.html">Git User&#8217;s Manual</a> provides a more
798 comprehensive introduction to git.</p></div>
799 <div class="paragraph"><p><a href="gitcvs-migration.html">gitcvs-migration(7)</a> explains how to
800 import a CVS repository into git, and shows how to use git in a
801 CVS-like way.</p></div>
802 <div class="paragraph"><p>For some interesting examples of git use, see the
803 <a href="howto-index.html">howtos</a>.</p></div>
804 <div class="paragraph"><p>For git developers, <a href="gitcore-tutorial.html">gitcore-tutorial(7)</a> goes
805 into detail on the lower-level git mechanisms involved in, for
806 example, creating a new commit.</p></div>
807 </div>
808 <h2 id="_see_also">SEE ALSO</h2>
809 <div class="sectionbody">
810 <div class="paragraph"><p><a href="gittutorial.html">gittutorial(7)</a>,
811 <a href="gitcvs-migration.html">gitcvs-migration(7)</a>,
812 <a href="gitcore-tutorial.html">gitcore-tutorial(7)</a>,
813 <a href="gitglossary.html">gitglossary(7)</a>,
814 <a href="git-help.html">git-help(1)</a>,
815 <a href="everyday.html">Everyday git</a>,
816 <a href="user-manual.html">The Git User&#8217;s Manual</a></p></div>
817 </div>
818 <h2 id="_git">GIT</h2>
819 <div class="sectionbody">
820 <div class="paragraph"><p>Part of the <a href="git.html">git(1)</a> suite.</p></div>
821 </div>
822 <div id="footer">
823 <div id="footer-text">
824 Last updated 2011-07-23 00:49:30 UTC
825 </div>
826 </div>
827 </body>
828 </html>