blob: ec0d28b4d1649192d8308d2556ee1e4aea11cc45 [file] [log] [blame]
Junio C Hamanodfccbb02008-05-26 01:16:141<!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>
Junio C Hamano9d971152012-12-19 00:43:115<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" />
Junio C Hamano446e30b2014-10-16 21:30:326<meta name="generator" content="AsciiDoc 8.6.9" />
Junio C Hamano97bcb482010-11-25 03:16:077<title>gittutorial-2(7)</title>
Junio C Hamanodfccbb02008-05-26 01:16:148<style type="text/css">
Junio C Hamano9d971152012-12-19 00:43:119/* Shared CSS for AsciiDoc xhtml11 and html5 backends */
10
11/* Default font. */
12body {
13 font-family: Georgia,serif;
14}
15
16/* Title font. */
17h1, h2, h3, h4, h5, h6,
18div.title, caption.title,
19thead, p.table.header,
20#toctitle,
21#author, #revnumber, #revdate, #revremark,
22#footer {
23 font-family: Arial,Helvetica,sans-serif;
Junio C Hamanodfccbb02008-05-26 01:16:1424}
25
26body {
27 margin: 1em 5% 1em 5%;
28}
29
Junio C Hamanoba4b9282008-07-06 05:20:3130a {
31 color: blue;
32 text-decoration: underline;
33}
34a:visited {
35 color: fuchsia;
36}
Junio C Hamanodfccbb02008-05-26 01:16:1437
38em {
39 font-style: italic;
Junio C Hamano97bcb482010-11-25 03:16:0740 color: navy;
Junio C Hamanodfccbb02008-05-26 01:16:1441}
42
43strong {
44 font-weight: bold;
Junio C Hamano97bcb482010-11-25 03:16:0745 color: #083194;
Junio C Hamanodfccbb02008-05-26 01:16:1446}
47
Junio C Hamanodfccbb02008-05-26 01:16:1448h1, h2, h3, h4, h5, h6 {
49 color: #527bbd;
Junio C Hamanodfccbb02008-05-26 01:16:1450 margin-top: 1.2em;
51 margin-bottom: 0.5em;
52 line-height: 1.3;
53}
54
Junio C Hamanoba4b9282008-07-06 05:20:3155h1, h2, h3 {
Junio C Hamanodfccbb02008-05-26 01:16:1456 border-bottom: 2px solid silver;
57}
58h2 {
Junio C Hamanodfccbb02008-05-26 01:16:1459 padding-top: 0.5em;
60}
Junio C Hamanoba4b9282008-07-06 05:20:3161h3 {
62 float: left;
63}
64h3 + * {
65 clear: left;
66}
Junio C Hamano9d971152012-12-19 00:43:1167h5 {
68 font-size: 1.0em;
69}
Junio C Hamanodfccbb02008-05-26 01:16:1470
71div.sectionbody {
Junio C Hamanodfccbb02008-05-26 01:16:1472 margin-left: 0;
73}
74
75hr {
76 border: 1px solid silver;
77}
78
79p {
80 margin-top: 0.5em;
81 margin-bottom: 0.5em;
82}
83
Junio C Hamano97bcb482010-11-25 03:16:0784ul, ol, li > p {
85 margin-top: 0;
86}
Junio C Hamano9d971152012-12-19 00:43:1187ul > li { color: #aaa; }
88ul > li > * { color: black; }
Junio C Hamano97bcb482010-11-25 03:16:0789
Junio C Hamano446e30b2014-10-16 21:30:3290.monospaced, code, pre {
91 font-family: "Courier New", Courier, monospace;
92 font-size: inherit;
93 color: navy;
Junio C Hamanodfccbb02008-05-26 01:16:1494 padding: 0;
95 margin: 0;
96}
Junio C Hamano446e30b2014-10-16 21:30:3297pre {
98 white-space: pre-wrap;
99}
Junio C Hamanodfccbb02008-05-26 01:16:14100
Junio C Hamano9d971152012-12-19 00:43:11101#author {
Junio C Hamanodfccbb02008-05-26 01:16:14102 color: #527bbd;
Junio C Hamanodfccbb02008-05-26 01:16:14103 font-weight: bold;
Junio C Hamanoba4b9282008-07-06 05:20:31104 font-size: 1.1em;
Junio C Hamanodfccbb02008-05-26 01:16:14105}
Junio C Hamano9d971152012-12-19 00:43:11106#email {
Junio C Hamanodfccbb02008-05-26 01:16:14107}
Junio C Hamano9d971152012-12-19 00:43:11108#revnumber, #revdate, #revremark {
Junio C Hamanodfccbb02008-05-26 01:16:14109}
110
Junio C Hamano9d971152012-12-19 00:43:11111#footer {
Junio C Hamanodfccbb02008-05-26 01:16:14112 font-size: small;
113 border-top: 2px solid silver;
114 padding-top: 0.5em;
115 margin-top: 4.0em;
116}
Junio C Hamano9d971152012-12-19 00:43:11117#footer-text {
Junio C Hamanodfccbb02008-05-26 01:16:14118 float: left;
119 padding-bottom: 0.5em;
120}
Junio C Hamano9d971152012-12-19 00:43:11121#footer-badges {
Junio C Hamanodfccbb02008-05-26 01:16:14122 float: right;
123 padding-bottom: 0.5em;
124}
125
Junio C Hamano9d971152012-12-19 00:43:11126#preamble {
Junio C Hamano97bcb482010-11-25 03:16:07127 margin-top: 1.5em;
128 margin-bottom: 1.5em;
129}
Junio C Hamano9d971152012-12-19 00:43:11130div.imageblock, div.exampleblock, div.verseblock,
Junio C Hamanodfccbb02008-05-26 01:16:14131div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock,
132div.admonitionblock {
Junio C Hamano7bd050f2011-09-22 06:32:22133 margin-top: 1.0em;
Junio C Hamanodfccbb02008-05-26 01:16:14134 margin-bottom: 1.5em;
135}
136div.admonitionblock {
Junio C Hamano7bd050f2011-09-22 06:32:22137 margin-top: 2.0em;
138 margin-bottom: 2.0em;
139 margin-right: 10%;
140 color: #606060;
Junio C Hamanodfccbb02008-05-26 01:16:14141}
142
143div.content { /* Block element content. */
144 padding: 0;
145}
146
147/* Block element titles. */
148div.title, caption.title {
Junio C Hamano97bcb482010-11-25 03:16:07149 color: #527bbd;
Junio C Hamanodfccbb02008-05-26 01:16:14150 font-weight: bold;
151 text-align: left;
152 margin-top: 1.0em;
153 margin-bottom: 0.5em;
154}
155div.title + * {
156 margin-top: 0;
157}
158
159td div.title:first-child {
160 margin-top: 0.0em;
161}
162div.content div.title:first-child {
163 margin-top: 0.0em;
164}
165div.content + div.title {
166 margin-top: 0.0em;
167}
168
169div.sidebarblock > div.content {
170 background: #ffffee;
Junio C Hamano9d971152012-12-19 00:43:11171 border: 1px solid #dddddd;
172 border-left: 4px solid #f0f0f0;
Junio C Hamanodfccbb02008-05-26 01:16:14173 padding: 0.5em;
174}
175
176div.listingblock > div.content {
Junio C Hamano9d971152012-12-19 00:43:11177 border: 1px solid #dddddd;
178 border-left: 5px solid #f0f0f0;
179 background: #f8f8f8;
Junio C Hamanodfccbb02008-05-26 01:16:14180 padding: 0.5em;
181}
182
Junio C Hamano7bd050f2011-09-22 06:32:22183div.quoteblock, div.verseblock {
184 padding-left: 1.0em;
185 margin-left: 1.0em;
Junio C Hamano97bcb482010-11-25 03:16:07186 margin-right: 10%;
Junio C Hamano9d971152012-12-19 00:43:11187 border-left: 5px solid #f0f0f0;
188 color: #888;
Junio C Hamanodfccbb02008-05-26 01:16:14189}
Junio C Hamano7bd050f2011-09-22 06:32:22190
Junio C Hamano97bcb482010-11-25 03:16:07191div.quoteblock > div.attribution {
192 padding-top: 0.5em;
Junio C Hamanodfccbb02008-05-26 01:16:14193 text-align: right;
194}
Junio C Hamano97bcb482010-11-25 03:16:07195
Junio C Hamano9d971152012-12-19 00:43:11196div.verseblock > pre.content {
197 font-family: inherit;
198 font-size: inherit;
Junio C Hamano97bcb482010-11-25 03:16:07199}
200div.verseblock > div.attribution {
201 padding-top: 0.75em;
202 text-align: left;
203}
204/* DEPRECATED: Pre version 8.2.7 verse style literal block. */
Junio C Hamanoba4b9282008-07-06 05:20:31205div.verseblock + div.attribution {
206 text-align: left;
207}
Junio C Hamanodfccbb02008-05-26 01:16:14208
209div.admonitionblock .icon {
210 vertical-align: top;
211 font-size: 1.1em;
212 font-weight: bold;
213 text-decoration: underline;
214 color: #527bbd;
215 padding-right: 0.5em;
216}
217div.admonitionblock td.content {
218 padding-left: 0.5em;
Junio C Hamano7bd050f2011-09-22 06:32:22219 border-left: 3px solid #dddddd;
Junio C Hamanodfccbb02008-05-26 01:16:14220}
221
222div.exampleblock > div.content {
Junio C Hamano7bd050f2011-09-22 06:32:22223 border-left: 3px solid #dddddd;
224 padding-left: 0.5em;
Junio C Hamanodfccbb02008-05-26 01:16:14225}
226
Junio C Hamanodfccbb02008-05-26 01:16:14227div.imageblock div.content { padding-left: 0; }
Junio C Hamano446e30b2014-10-16 21:30:32228span.image img { border-style: none; vertical-align: text-bottom; }
Junio C Hamano97bcb482010-11-25 03:16:07229a.image:visited { color: white; }
Junio C Hamanodfccbb02008-05-26 01:16:14230
231dl {
232 margin-top: 0.8em;
233 margin-bottom: 0.8em;
234}
235dt {
236 margin-top: 0.5em;
237 margin-bottom: 0;
Junio C Hamano97bcb482010-11-25 03:16:07238 font-style: normal;
239 color: navy;
Junio C Hamanodfccbb02008-05-26 01:16:14240}
241dd > *:first-child {
Junio C Hamano97bcb482010-11-25 03:16:07242 margin-top: 0.1em;
Junio C Hamanodfccbb02008-05-26 01:16:14243}
244
245ul, ol {
246 list-style-position: outside;
247}
Junio C Hamano97bcb482010-11-25 03:16:07248ol.arabic {
249 list-style-type: decimal;
250}
251ol.loweralpha {
Junio C Hamanodfccbb02008-05-26 01:16:14252 list-style-type: lower-alpha;
253}
Junio C Hamano97bcb482010-11-25 03:16:07254ol.upperalpha {
255 list-style-type: upper-alpha;
256}
257ol.lowerroman {
258 list-style-type: lower-roman;
259}
260ol.upperroman {
261 list-style-type: upper-roman;
262}
263
264div.compact ul, div.compact ol,
265div.compact p, div.compact p,
266div.compact div, div.compact div {
267 margin-top: 0.1em;
268 margin-bottom: 0.1em;
269}
Junio C Hamanodfccbb02008-05-26 01:16:14270
Junio C Hamanodfccbb02008-05-26 01:16:14271tfoot {
272 font-weight: bold;
273}
Junio C Hamano97bcb482010-11-25 03:16:07274td > div.verse {
275 white-space: pre;
276}
Junio C Hamano97bcb482010-11-25 03:16:07277
278div.hdlist {
Junio C Hamanodfccbb02008-05-26 01:16:14279 margin-top: 0.8em;
280 margin-bottom: 0.8em;
281}
Junio C Hamano97bcb482010-11-25 03:16:07282div.hdlist tr {
283 padding-bottom: 15px;
Junio C Hamanoba4b9282008-07-06 05:20:31284}
Junio C Hamano97bcb482010-11-25 03:16:07285dt.hdlist1.strong, td.hdlist1.strong {
286 font-weight: bold;
287}
288td.hdlist1 {
Junio C Hamanodfccbb02008-05-26 01:16:14289 vertical-align: top;
Junio C Hamano97bcb482010-11-25 03:16:07290 font-style: normal;
Junio C Hamanodfccbb02008-05-26 01:16:14291 padding-right: 0.8em;
Junio C Hamano97bcb482010-11-25 03:16:07292 color: navy;
Junio C Hamanodfccbb02008-05-26 01:16:14293}
Junio C Hamano97bcb482010-11-25 03:16:07294td.hdlist2 {
Junio C Hamanodfccbb02008-05-26 01:16:14295 vertical-align: top;
296}
Junio C Hamano97bcb482010-11-25 03:16:07297div.hdlist.compact tr {
298 margin: 0;
299 padding-bottom: 0;
300}
301
302.comment {
303 background: yellow;
304}
Junio C Hamanodfccbb02008-05-26 01:16:14305
Junio C Hamano7bd050f2011-09-22 06:32:22306.footnote, .footnoteref {
307 font-size: 0.8em;
308}
309
310span.footnote, span.footnoteref {
311 vertical-align: super;
312}
313
314#footnotes {
315 margin: 20px 0 20px 0;
316 padding: 7px 0 0 0;
317}
318
319#footnotes div.footnote {
320 margin: 0 0 5px 0;
321}
322
323#footnotes hr {
324 border: none;
325 border-top: 1px solid silver;
326 height: 1px;
327 text-align: left;
328 margin-left: 0;
329 width: 20%;
330 min-width: 100px;
331}
332
Junio C Hamano9d971152012-12-19 00:43:11333div.colist td {
334 padding-right: 0.5em;
335 padding-bottom: 0.3em;
336 vertical-align: top;
337}
338div.colist td img {
339 margin-top: 0.3em;
Junio C Hamanodfccbb02008-05-26 01:16:14340}
Junio C Hamanoba4b9282008-07-06 05:20:31341
Junio C Hamano9d971152012-12-19 00:43:11342@media print {
343 #footer-badges { display: none; }
344}
345
346#toc {
Junio C Hamano7bd050f2011-09-22 06:32:22347 margin-bottom: 2.5em;
348}
349
Junio C Hamano9d971152012-12-19 00:43:11350#toctitle {
Junio C Hamanoba4b9282008-07-06 05:20:31351 color: #527bbd;
Junio C Hamanoba4b9282008-07-06 05:20:31352 font-size: 1.1em;
353 font-weight: bold;
354 margin-top: 1.0em;
355 margin-bottom: 0.1em;
356}
357
Junio C Hamano446e30b2014-10-16 21:30:32358div.toclevel0, div.toclevel1, div.toclevel2, div.toclevel3, div.toclevel4 {
Junio C Hamanoba4b9282008-07-06 05:20:31359 margin-top: 0;
360 margin-bottom: 0;
361}
362div.toclevel2 {
363 margin-left: 2em;
364 font-size: 0.9em;
365}
366div.toclevel3 {
367 margin-left: 4em;
368 font-size: 0.9em;
369}
370div.toclevel4 {
371 margin-left: 6em;
372 font-size: 0.9em;
373}
Junio C Hamano9d971152012-12-19 00:43:11374
375span.aqua { color: aqua; }
376span.black { color: black; }
377span.blue { color: blue; }
378span.fuchsia { color: fuchsia; }
379span.gray { color: gray; }
380span.green { color: green; }
381span.lime { color: lime; }
382span.maroon { color: maroon; }
383span.navy { color: navy; }
384span.olive { color: olive; }
385span.purple { color: purple; }
386span.red { color: red; }
387span.silver { color: silver; }
388span.teal { color: teal; }
389span.white { color: white; }
390span.yellow { color: yellow; }
391
392span.aqua-background { background: aqua; }
393span.black-background { background: black; }
394span.blue-background { background: blue; }
395span.fuchsia-background { background: fuchsia; }
396span.gray-background { background: gray; }
397span.green-background { background: green; }
398span.lime-background { background: lime; }
399span.maroon-background { background: maroon; }
400span.navy-background { background: navy; }
401span.olive-background { background: olive; }
402span.purple-background { background: purple; }
403span.red-background { background: red; }
404span.silver-background { background: silver; }
405span.teal-background { background: teal; }
406span.white-background { background: white; }
407span.yellow-background { background: yellow; }
408
409span.big { font-size: 2em; }
410span.small { font-size: 0.6em; }
411
412span.underline { text-decoration: underline; }
413span.overline { text-decoration: overline; }
414span.line-through { text-decoration: line-through; }
415
Junio C Hamano446e30b2014-10-16 21:30:32416div.unbreakable { page-break-inside: avoid; }
417
Junio C Hamano9d971152012-12-19 00:43:11418
419/*
420 * xhtml11 specific
421 *
422 * */
423
424div.tableblock {
425 margin-top: 1.0em;
426 margin-bottom: 1.5em;
427}
428div.tableblock > table {
429 border: 3px solid #527bbd;
430}
431thead, p.table.header {
432 font-weight: bold;
433 color: #527bbd;
434}
435p.table {
436 margin-top: 0;
437}
438/* Because the table frame attribute is overriden by CSS in most browsers. */
439div.tableblock > table[frame="void"] {
440 border-style: none;
441}
442div.tableblock > table[frame="hsides"] {
443 border-left-style: none;
444 border-right-style: none;
445}
446div.tableblock > table[frame="vsides"] {
447 border-top-style: none;
448 border-bottom-style: none;
449}
450
451
452/*
453 * html5 specific
454 *
455 * */
456
457table.tableblock {
458 margin-top: 1.0em;
459 margin-bottom: 1.5em;
460}
461thead, p.tableblock.header {
462 font-weight: bold;
463 color: #527bbd;
464}
465p.tableblock {
466 margin-top: 0;
467}
468table.tableblock {
469 border-width: 3px;
470 border-spacing: 0px;
471 border-style: solid;
472 border-color: #527bbd;
473 border-collapse: collapse;
474}
475th.tableblock, td.tableblock {
476 border-width: 1px;
477 padding: 4px;
478 border-style: solid;
479 border-color: #527bbd;
480}
481
482table.tableblock.frame-topbot {
483 border-left-style: hidden;
484 border-right-style: hidden;
485}
486table.tableblock.frame-sides {
487 border-top-style: hidden;
488 border-bottom-style: hidden;
489}
490table.tableblock.frame-none {
491 border-style: hidden;
492}
493
494th.tableblock.halign-left, td.tableblock.halign-left {
495 text-align: left;
496}
497th.tableblock.halign-center, td.tableblock.halign-center {
498 text-align: center;
499}
500th.tableblock.halign-right, td.tableblock.halign-right {
501 text-align: right;
502}
503
504th.tableblock.valign-top, td.tableblock.valign-top {
505 vertical-align: top;
506}
507th.tableblock.valign-middle, td.tableblock.valign-middle {
508 vertical-align: middle;
509}
510th.tableblock.valign-bottom, td.tableblock.valign-bottom {
511 vertical-align: bottom;
512}
513
514
515/*
516 * manpage specific
517 *
518 * */
519
520body.manpage h1 {
Junio C Hamano97bcb482010-11-25 03:16:07521 padding-top: 0.5em;
522 padding-bottom: 0.5em;
523 border-top: 2px solid silver;
524 border-bottom: 2px solid silver;
525}
Junio C Hamano9d971152012-12-19 00:43:11526body.manpage h2 {
Junio C Hamano97bcb482010-11-25 03:16:07527 border-style: none;
528}
Junio C Hamano9d971152012-12-19 00:43:11529body.manpage div.sectionbody {
530 margin-left: 3em;
Junio C Hamano97bcb482010-11-25 03:16:07531}
532
533@media print {
Junio C Hamano9d971152012-12-19 00:43:11534 body.manpage div#toc { display: none; }
Junio C Hamano97bcb482010-11-25 03:16:07535}
Junio C Hamano446e30b2014-10-16 21:30:32536
537
Junio C Hamanodfccbb02008-05-26 01:16:14538</style>
Junio C Hamano7bd050f2011-09-22 06:32:22539<script type="text/javascript">
540/*<![CDATA[*/
Junio C Hamano7bd050f2011-09-22 06:32:22541var asciidoc = { // Namespace.
542
543/////////////////////////////////////////////////////////////////////
544// Table Of Contents generator
545/////////////////////////////////////////////////////////////////////
546
547/* Author: Mihai Bazon, September 2002
548 * http://students.infoiasi.ro/~mishoo
549 *
550 * Table Of Content generator
551 * Version: 0.4
552 *
553 * Feel free to use this script under the terms of the GNU General Public
554 * License, as long as you do not remove or alter this notice.
555 */
556
557 /* modified by Troy D. Hanson, September 2006. License: GPL */
558 /* modified by Stuart Rackham, 2006, 2009. License: GPL */
559
560// toclevels = 1..4.
561toc: function (toclevels) {
562
563 function getText(el) {
564 var text = "";
565 for (var i = el.firstChild; i != null; i = i.nextSibling) {
566 if (i.nodeType == 3 /* Node.TEXT_NODE */) // IE doesn't speak constants.
567 text += i.data;
568 else if (i.firstChild != null)
569 text += getText(i);
570 }
571 return text;
572 }
573
574 function TocEntry(el, text, toclevel) {
575 this.element = el;
576 this.text = text;
577 this.toclevel = toclevel;
578 }
579
580 function tocEntries(el, toclevels) {
581 var result = new Array;
Junio C Hamano446e30b2014-10-16 21:30:32582 var re = new RegExp('[hH]([1-'+(toclevels+1)+'])');
Junio C Hamano7bd050f2011-09-22 06:32:22583 // Function that scans the DOM tree for header elements (the DOM2
584 // nodeIterator API would be a better technique but not supported by all
585 // browsers).
586 var iterate = function (el) {
587 for (var i = el.firstChild; i != null; i = i.nextSibling) {
588 if (i.nodeType == 1 /* Node.ELEMENT_NODE */) {
589 var mo = re.exec(i.tagName);
590 if (mo && (i.getAttribute("class") || i.getAttribute("className")) != "float") {
591 result[result.length] = new TocEntry(i, getText(i), mo[1]-1);
592 }
593 iterate(i);
594 }
595 }
596 }
597 iterate(el);
598 return result;
599 }
600
601 var toc = document.getElementById("toc");
Junio C Hamano9d971152012-12-19 00:43:11602 if (!toc) {
603 return;
604 }
605
606 // Delete existing TOC entries in case we're reloading the TOC.
607 var tocEntriesToRemove = [];
608 var i;
609 for (i = 0; i < toc.childNodes.length; i++) {
610 var entry = toc.childNodes[i];
Junio C Hamano446e30b2014-10-16 21:30:32611 if (entry.nodeName.toLowerCase() == 'div'
Junio C Hamano9d971152012-12-19 00:43:11612 && entry.getAttribute("class")
613 && entry.getAttribute("class").match(/^toclevel/))
614 tocEntriesToRemove.push(entry);
615 }
616 for (i = 0; i < tocEntriesToRemove.length; i++) {
617 toc.removeChild(tocEntriesToRemove[i]);
618 }
619
620 // Rebuild TOC entries.
Junio C Hamano7bd050f2011-09-22 06:32:22621 var entries = tocEntries(document.getElementById("content"), toclevels);
622 for (var i = 0; i < entries.length; ++i) {
623 var entry = entries[i];
624 if (entry.element.id == "")
625 entry.element.id = "_toc_" + i;
626 var a = document.createElement("a");
627 a.href = "#" + entry.element.id;
628 a.appendChild(document.createTextNode(entry.text));
629 var div = document.createElement("div");
630 div.appendChild(a);
631 div.className = "toclevel" + entry.toclevel;
632 toc.appendChild(div);
633 }
634 if (entries.length == 0)
635 toc.parentNode.removeChild(toc);
636},
637
638
639/////////////////////////////////////////////////////////////////////
640// Footnotes generator
641/////////////////////////////////////////////////////////////////////
642
643/* Based on footnote generation code from:
644 * http://www.brandspankingnew.net/archive/2005/07/format_footnote.html
645 */
646
647footnotes: function () {
Junio C Hamano9d971152012-12-19 00:43:11648 // Delete existing footnote entries in case we're reloading the footnodes.
649 var i;
Junio C Hamano7bd050f2011-09-22 06:32:22650 var noteholder = document.getElementById("footnotes");
Junio C Hamano9d971152012-12-19 00:43:11651 if (!noteholder) {
652 return;
653 }
654 var entriesToRemove = [];
655 for (i = 0; i < noteholder.childNodes.length; i++) {
656 var entry = noteholder.childNodes[i];
Junio C Hamano446e30b2014-10-16 21:30:32657 if (entry.nodeName.toLowerCase() == 'div' && entry.getAttribute("class") == "footnote")
Junio C Hamano9d971152012-12-19 00:43:11658 entriesToRemove.push(entry);
659 }
660 for (i = 0; i < entriesToRemove.length; i++) {
661 noteholder.removeChild(entriesToRemove[i]);
662 }
663
664 // Rebuild footnote entries.
665 var cont = document.getElementById("content");
Junio C Hamano7bd050f2011-09-22 06:32:22666 var spans = cont.getElementsByTagName("span");
667 var refs = {};
668 var n = 0;
669 for (i=0; i<spans.length; i++) {
670 if (spans[i].className == "footnote") {
671 n++;
Junio C Hamano9d971152012-12-19 00:43:11672 var note = spans[i].getAttribute("data-note");
673 if (!note) {
674 // Use [\s\S] in place of . so multi-line matches work.
675 // Because JavaScript has no s (dotall) regex flag.
676 note = spans[i].innerHTML.match(/\s*\[([\s\S]*)]\s*/)[1];
677 spans[i].innerHTML =
678 "[<a id='_footnoteref_" + n + "' href='#_footnote_" + n +
679 "' title='View footnote' class='footnote'>" + n + "</a>]";
680 spans[i].setAttribute("data-note", note);
681 }
Junio C Hamano7bd050f2011-09-22 06:32:22682 noteholder.innerHTML +=
683 "<div class='footnote' id='_footnote_" + n + "'>" +
684 "<a href='#_footnoteref_" + n + "' title='Return to text'>" +
685 n + "</a>. " + note + "</div>";
Junio C Hamano7bd050f2011-09-22 06:32:22686 var id =spans[i].getAttribute("id");
687 if (id != null) refs["#"+id] = n;
688 }
689 }
690 if (n == 0)
691 noteholder.parentNode.removeChild(noteholder);
692 else {
693 // Process footnoterefs.
694 for (i=0; i<spans.length; i++) {
695 if (spans[i].className == "footnoteref") {
696 var href = spans[i].getElementsByTagName("a")[0].getAttribute("href");
697 href = href.match(/#.*/)[0]; // Because IE return full URL.
698 n = refs[href];
699 spans[i].innerHTML =
700 "[<a href='#_footnote_" + n +
701 "' title='View footnote' class='footnote'>" + n + "</a>]";
702 }
703 }
704 }
Junio C Hamano9d971152012-12-19 00:43:11705},
706
707install: function(toclevels) {
708 var timerId;
709
710 function reinstall() {
711 asciidoc.footnotes();
712 if (toclevels) {
713 asciidoc.toc(toclevels);
714 }
715 }
716
717 function reinstallAndRemoveTimer() {
718 clearInterval(timerId);
719 reinstall();
720 }
721
722 timerId = setInterval(reinstall, 500);
723 if (document.addEventListener)
724 document.addEventListener("DOMContentLoaded", reinstallAndRemoveTimer, false);
725 else
726 window.onload = reinstallAndRemoveTimer;
Junio C Hamano7bd050f2011-09-22 06:32:22727}
728
729}
Junio C Hamano9d971152012-12-19 00:43:11730asciidoc.install();
Junio C Hamano7bd050f2011-09-22 06:32:22731/*]]>*/
732</script>
Junio C Hamanodfccbb02008-05-26 01:16:14733</head>
Junio C Hamano9d971152012-12-19 00:43:11734<body class="manpage">
Junio C Hamanodfccbb02008-05-26 01:16:14735<div id="header">
736<h1>
737gittutorial-2(7) Manual Page
738</h1>
739<h2>NAME</h2>
740<div class="sectionbody">
741<p>gittutorial-2 -
Junio C Hamano076ffcc2013-02-06 05:13:21742 A tutorial introduction to Git: part two
Junio C Hamanodfccbb02008-05-26 01:16:14743</p>
744</div>
745</div>
Junio C Hamano7bd050f2011-09-22 06:32:22746<div id="content">
Junio C Hamano9d971152012-12-19 00:43:11747<div class="sect1">
Junio C Hamano97bcb482010-11-25 03:16:07748<h2 id="_synopsis">SYNOPSIS</h2>
Junio C Hamanodfccbb02008-05-26 01:16:14749<div class="sectionbody">
Junio C Hamano15567bc2011-07-23 00:51:59750<div class="verseblock">
Junio C Hamano9d971152012-12-19 00:43:11751<pre class="content">git *</pre>
752<div class="attribution">
Junio C Hamano15567bc2011-07-23 00:51:59753</div></div>
Junio C Hamanodfccbb02008-05-26 01:16:14754</div>
Junio C Hamano9d971152012-12-19 00:43:11755</div>
756<div class="sect1">
Junio C Hamanoba4b9282008-07-06 05:20:31757<h2 id="_description">DESCRIPTION</h2>
Junio C Hamanodfccbb02008-05-26 01:16:14758<div class="sectionbody">
Junio C Hamanoa28a9202012-06-21 07:08:23759<div class="paragraph"><p>You should work through <a href="gittutorial.html">gittutorial(7)</a> before reading this tutorial.</p></div>
Junio C Hamano97bcb482010-11-25 03:16:07760<div class="paragraph"><p>The goal of this tutorial is to introduce two fundamental pieces of
Junio C Hamano076ffcc2013-02-06 05:13:21761Git&#8217;s architecture&#8212;the object database and the index file&#8212;and to
Junio C Hamanodfccbb02008-05-26 01:16:14762provide the reader with everything necessary to understand the rest
Junio C Hamano076ffcc2013-02-06 05:13:21763of the Git documentation.</p></div>
Junio C Hamanodfccbb02008-05-26 01:16:14764</div>
Junio C Hamano9d971152012-12-19 00:43:11765</div>
766<div class="sect1">
Junio C Hamano076ffcc2013-02-06 05:13:21767<h2 id="_the_git_object_database">The Git object database</h2>
Junio C Hamanodfccbb02008-05-26 01:16:14768<div class="sectionbody">
Junio C Hamano97bcb482010-11-25 03:16:07769<div class="paragraph"><p>Let&#8217;s start a new project and create a small amount of history:</p></div>
Junio C Hamanodfccbb02008-05-26 01:16:14770<div class="listingblock">
771<div class="content">
Junio C Hamano446e30b2014-10-16 21:30:32772<pre><code>$ mkdir test-project
Junio C Hamanodfccbb02008-05-26 01:16:14773$ cd test-project
774$ git init
775Initialized empty Git repository in .git/
776$ echo 'hello world' &gt; file.txt
777$ git add .
778$ git commit -a -m "initial commit"
Junio C Hamanobc4852e2009-01-21 10:51:14779[master (root-commit) 54196cc] initial commit
Junio C Hamanod3004032012-02-13 08:09:03780 1 file changed, 1 insertion(+)
Junio C Hamanodfccbb02008-05-26 01:16:14781 create mode 100644 file.txt
782$ echo 'hello world!' &gt;file.txt
783$ git commit -a -m "add emphasis"
Junio C Hamanobc4852e2009-01-21 10:51:14784[master c4d59f3] add emphasis
Junio C Hamano446e30b2014-10-16 21:30:32785 1 file changed, 1 insertion(+), 1 deletion(-)</code></pre>
Junio C Hamanodfccbb02008-05-26 01:16:14786</div></div>
Junio C Hamano076ffcc2013-02-06 05:13:21787<div class="paragraph"><p>What are the 7 digits of hex that Git responded to the commit with?</p></div>
Junio C Hamano97bcb482010-11-25 03:16:07788<div class="paragraph"><p>We saw in part one of the tutorial that commits have names like this.
Junio C Hamano076ffcc2013-02-06 05:13:21789It turns out that every object in the Git history is stored under
Junio C Hamanoe3f080d2013-04-22 02:27:13790a 40-digit hex name. That name is the SHA-1 hash of the object&#8217;s
Junio C Hamano076ffcc2013-02-06 05:13:21791contents; among other things, this ensures that Git will never store
Junio C Hamanoe3f080d2013-04-22 02:27:13792the same data twice (since identical data is given an identical SHA-1
Junio C Hamano076ffcc2013-02-06 05:13:21793name), and that the contents of a Git object will never change (since
Junio C Hamano97bcb482010-11-25 03:16:07794that would change the object&#8217;s name as well). The 7 char hex strings
Junio C Hamanoa2deec52008-10-18 18:58:09795here are simply the abbreviation of such 40 character long strings.
796Abbreviations can be used everywhere where the 40 character strings
797can be used, so long as they are unambiguous.</p></div>
Junio C Hamano97bcb482010-11-25 03:16:07798<div class="paragraph"><p>It is expected that the content of the commit object you created while
Junio C Hamanoe3f080d2013-04-22 02:27:13799following the example above generates a different SHA-1 hash than
Junio C Hamanodfccbb02008-05-26 01:16:14800the one shown above because the commit object records the time when
Junio C Hamanoba4b9282008-07-06 05:20:31801it was created and the name of the person performing the commit.</p></div>
Junio C Hamano446e30b2014-10-16 21:30:32802<div class="paragraph"><p>We can ask Git about this particular object with the <code>cat-file</code>
Junio C Hamano97bcb482010-11-25 03:16:07803command. Don&#8217;t copy the 40 hex digits from this example but use those
Junio C Hamanodfccbb02008-05-26 01:16:14804from your own version. Note that you can shorten it to only a few
Junio C Hamanoba4b9282008-07-06 05:20:31805characters to save yourself typing all 40 hex digits:</p></div>
Junio C Hamanodfccbb02008-05-26 01:16:14806<div class="listingblock">
807<div class="content">
Junio C Hamano446e30b2014-10-16 21:30:32808<pre><code>$ git cat-file -t 54196cc2
Junio C Hamanodfccbb02008-05-26 01:16:14809commit
Junio C Hamano432d8ee2008-06-27 08:26:43810$ git cat-file commit 54196cc2
Junio C Hamanodfccbb02008-05-26 01:16:14811tree 92b8b694ffb1675e5975148e1121810081dbdffe
812author J. Bruce Fields &lt;bfields@puzzle.fieldses.org&gt; 1143414668 -0500
813committer J. Bruce Fields &lt;bfields@puzzle.fieldses.org&gt; 1143414668 -0500
814
Junio C Hamano446e30b2014-10-16 21:30:32815initial commit</code></pre>
Junio C Hamanodfccbb02008-05-26 01:16:14816</div></div>
Junio C Hamano97bcb482010-11-25 03:16:07817<div class="paragraph"><p>A tree can refer to one or more "blob" objects, each corresponding to
Junio C Hamanodfccbb02008-05-26 01:16:14818a file. In addition, a tree can also refer to other tree objects,
819thus creating a directory hierarchy. You can examine the contents of
820any tree using ls-tree (remember that a long enough initial portion
Junio C Hamanoe3f080d2013-04-22 02:27:13821of the SHA-1 will also work):</p></div>
Junio C Hamanodfccbb02008-05-26 01:16:14822<div class="listingblock">
823<div class="content">
Junio C Hamano446e30b2014-10-16 21:30:32824<pre><code>$ git ls-tree 92b8b694
825100644 blob 3b18e512dba79e4c8300dd08aeb37f8e728b8dad file.txt</code></pre>
Junio C Hamanodfccbb02008-05-26 01:16:14826</div></div>
Junio C Hamanoe3f080d2013-04-22 02:27:13827<div class="paragraph"><p>Thus we see that this tree has one file in it. The SHA-1 hash is a
Junio C Hamano97bcb482010-11-25 03:16:07828reference to that file&#8217;s data:</p></div>
Junio C Hamanodfccbb02008-05-26 01:16:14829<div class="listingblock">
830<div class="content">
Junio C Hamano446e30b2014-10-16 21:30:32831<pre><code>$ git cat-file -t 3b18e512
832blob</code></pre>
Junio C Hamanodfccbb02008-05-26 01:16:14833</div></div>
Junio C Hamano97bcb482010-11-25 03:16:07834<div class="paragraph"><p>A "blob" is just file data, which we can also examine with cat-file:</p></div>
Junio C Hamanodfccbb02008-05-26 01:16:14835<div class="listingblock">
836<div class="content">
Junio C Hamano446e30b2014-10-16 21:30:32837<pre><code>$ git cat-file blob 3b18e512
838hello world</code></pre>
Junio C Hamanodfccbb02008-05-26 01:16:14839</div></div>
Junio C Hamano076ffcc2013-02-06 05:13:21840<div class="paragraph"><p>Note that this is the old file data; so the object that Git named in
Junio C Hamanodfccbb02008-05-26 01:16:14841its response to the initial tree was a tree with a snapshot of the
Junio C Hamanoba4b9282008-07-06 05:20:31842directory state that was recorded by the first commit.</p></div>
Junio C Hamanoe3f080d2013-04-22 02:27:13843<div class="paragraph"><p>All of these objects are stored under their SHA-1 names inside the Git
Junio C Hamanoba4b9282008-07-06 05:20:31844directory:</p></div>
Junio C Hamanodfccbb02008-05-26 01:16:14845<div class="listingblock">
846<div class="content">
Junio C Hamano446e30b2014-10-16 21:30:32847<pre><code>$ find .git/objects/
Junio C Hamanodfccbb02008-05-26 01:16:14848.git/objects/
849.git/objects/pack
850.git/objects/info
851.git/objects/3b
852.git/objects/3b/18e512dba79e4c8300dd08aeb37f8e728b8dad
853.git/objects/92
854.git/objects/92/b8b694ffb1675e5975148e1121810081dbdffe
855.git/objects/54
856.git/objects/54/196cc2703dc165cbd373a65a4dcf22d50ae7f7
857.git/objects/a0
858.git/objects/a0/423896973644771497bdc03eb99d5281615b51
859.git/objects/d0
860.git/objects/d0/492b368b66bdabf2ac1fd8c92b39d3db916e59
861.git/objects/c4
Junio C Hamano446e30b2014-10-16 21:30:32862.git/objects/c4/d59f390b9cfd4318117afde11d601c1085f241</code></pre>
Junio C Hamanodfccbb02008-05-26 01:16:14863</div></div>
Junio C Hamano97bcb482010-11-25 03:16:07864<div class="paragraph"><p>and the contents of these files is just the compressed data plus a
Junio C Hamanodfccbb02008-05-26 01:16:14865header identifying their length and their type. The type is either a
Junio C Hamanoba4b9282008-07-06 05:20:31866blob, a tree, a commit, or a tag.</p></div>
Junio C Hamano97bcb482010-11-25 03:16:07867<div class="paragraph"><p>The simplest commit to find is the HEAD commit, which we can find
Junio C Hamanoba4b9282008-07-06 05:20:31868from .git/HEAD:</p></div>
Junio C Hamanodfccbb02008-05-26 01:16:14869<div class="listingblock">
870<div class="content">
Junio C Hamano446e30b2014-10-16 21:30:32871<pre><code>$ cat .git/HEAD
872ref: refs/heads/master</code></pre>
Junio C Hamanodfccbb02008-05-26 01:16:14873</div></div>
Junio C Hamano97bcb482010-11-25 03:16:07874<div class="paragraph"><p>As you can see, this tells us which branch we&#8217;re currently on, and it
Junio C Hamanodfccbb02008-05-26 01:16:14875tells us this by naming a file under the .git directory, which itself
Junio C Hamanoe3f080d2013-04-22 02:27:13876contains a SHA-1 name referring to a commit object, which we can
Junio C Hamanoba4b9282008-07-06 05:20:31877examine with cat-file:</p></div>
Junio C Hamanodfccbb02008-05-26 01:16:14878<div class="listingblock">
879<div class="content">
Junio C Hamano446e30b2014-10-16 21:30:32880<pre><code>$ cat .git/refs/heads/master
Junio C Hamanodfccbb02008-05-26 01:16:14881c4d59f390b9cfd4318117afde11d601c1085f241
882$ git cat-file -t c4d59f39
883commit
884$ git cat-file commit c4d59f39
885tree d0492b368b66bdabf2ac1fd8c92b39d3db916e59
886parent 54196cc2703dc165cbd373a65a4dcf22d50ae7f7
887author J. Bruce Fields &lt;bfields@puzzle.fieldses.org&gt; 1143418702 -0500
888committer J. Bruce Fields &lt;bfields@puzzle.fieldses.org&gt; 1143418702 -0500
889
Junio C Hamano446e30b2014-10-16 21:30:32890add emphasis</code></pre>
Junio C Hamanodfccbb02008-05-26 01:16:14891</div></div>
Junio C Hamano97bcb482010-11-25 03:16:07892<div class="paragraph"><p>The "tree" object here refers to the new state of the tree:</p></div>
Junio C Hamanodfccbb02008-05-26 01:16:14893<div class="listingblock">
894<div class="content">
Junio C Hamano446e30b2014-10-16 21:30:32895<pre><code>$ git ls-tree d0492b36
Junio C Hamanodfccbb02008-05-26 01:16:14896100644 blob a0423896973644771497bdc03eb99d5281615b51 file.txt
897$ git cat-file blob a0423896
Junio C Hamano446e30b2014-10-16 21:30:32898hello world!</code></pre>
Junio C Hamanodfccbb02008-05-26 01:16:14899</div></div>
Junio C Hamano97bcb482010-11-25 03:16:07900<div class="paragraph"><p>and the "parent" object refers to the previous commit:</p></div>
Junio C Hamanodfccbb02008-05-26 01:16:14901<div class="listingblock">
902<div class="content">
Junio C Hamano446e30b2014-10-16 21:30:32903<pre><code>$ git cat-file commit 54196cc2
Junio C Hamanodfccbb02008-05-26 01:16:14904tree 92b8b694ffb1675e5975148e1121810081dbdffe
905author J. Bruce Fields &lt;bfields@puzzle.fieldses.org&gt; 1143414668 -0500
906committer J. Bruce Fields &lt;bfields@puzzle.fieldses.org&gt; 1143414668 -0500
907
Junio C Hamano446e30b2014-10-16 21:30:32908initial commit</code></pre>
Junio C Hamanodfccbb02008-05-26 01:16:14909</div></div>
Junio C Hamano97bcb482010-11-25 03:16:07910<div class="paragraph"><p>The tree object is the tree we examined first, and this commit is
Junio C Hamanoba4b9282008-07-06 05:20:31911unusual in that it lacks any parent.</p></div>
Junio C Hamano97bcb482010-11-25 03:16:07912<div class="paragraph"><p>Most commits have only one parent, but it is also common for a commit
Junio C Hamanodfccbb02008-05-26 01:16:14913to have multiple parents. In that case the commit represents a
914merge, with the parent references pointing to the heads of the merged
Junio C Hamanoba4b9282008-07-06 05:20:31915branches.</p></div>
Junio C Hamano97bcb482010-11-25 03:16:07916<div class="paragraph"><p>Besides blobs, trees, and commits, the only remaining type of object
Junio C Hamanoa28a9202012-06-21 07:08:23917is a "tag", which we won&#8217;t discuss here; refer to <a href="git-tag.html">git-tag(1)</a>
Junio C Hamanoba4b9282008-07-06 05:20:31918for details.</p></div>
Junio C Hamano076ffcc2013-02-06 05:13:21919<div class="paragraph"><p>So now we know how Git uses the object database to represent a
Junio C Hamano97bcb482010-11-25 03:16:07920project&#8217;s history:</p></div>
921<div class="ulist"><ul>
Junio C Hamanodfccbb02008-05-26 01:16:14922<li>
923<p>
924"commit" objects refer to "tree" objects representing the
925 snapshot of a directory tree at a particular point in the
Junio C Hamano97bcb482010-11-25 03:16:07926 history, and refer to "parent" commits to show how they&#8217;re
Junio C Hamanodfccbb02008-05-26 01:16:14927 connected into the project history.
928</p>
929</li>
930<li>
931<p>
932"tree" objects represent the state of a single directory,
933 associating directory names to "blob" objects containing file
934 data and "tree" objects containing subdirectory information.
935</p>
936</li>
937<li>
938<p>
939"blob" objects contain file data without any other structure.
940</p>
941</li>
942<li>
943<p>
944References to commit objects at the head of each branch are
945 stored in files under .git/refs/heads/.
946</p>
947</li>
948<li>
949<p>
950The name of the current branch is stored in .git/HEAD.
951</p>
952</li>
Junio C Hamanoba4b9282008-07-06 05:20:31953</ul></div>
Junio C Hamano97bcb482010-11-25 03:16:07954<div class="paragraph"><p>Note, by the way, that lots of commands take a tree as an argument.
Junio C Hamanodfccbb02008-05-26 01:16:14955But as we can see above, a tree can be referred to in many different
Junio C Hamanoe3f080d2013-04-22 02:27:13956ways&#8212;by the SHA-1 name for that tree, by the name of a commit that
Junio C Hamanodfccbb02008-05-26 01:16:14957refers to the tree, by the name of a branch whose head refers to that
Junio C Hamanoba4b9282008-07-06 05:20:31958tree, etc.--and most such commands can accept any of these names.</p></div>
Junio C Hamano97bcb482010-11-25 03:16:07959<div class="paragraph"><p>In command synopses, the word "tree-ish" is sometimes used to
Junio C Hamanoba4b9282008-07-06 05:20:31960designate such an argument.</p></div>
Junio C Hamanodfccbb02008-05-26 01:16:14961</div>
Junio C Hamano9d971152012-12-19 00:43:11962</div>
963<div class="sect1">
Junio C Hamanoba4b9282008-07-06 05:20:31964<h2 id="_the_index_file">The index file</h2>
Junio C Hamanodfccbb02008-05-26 01:16:14965<div class="sectionbody">
Junio C Hamano446e30b2014-10-16 21:30:32966<div class="paragraph"><p>The primary tool we&#8217;ve been using to create commits is <code>git-commit
967-a</code>, which creates a commit including every change you&#8217;ve made to
Junio C Hamanodfccbb02008-05-26 01:16:14968your working tree. But what if you want to commit changes only to
Junio C Hamanoba4b9282008-07-06 05:20:31969certain files? Or only certain changes to certain files?</p></div>
Junio C Hamano97bcb482010-11-25 03:16:07970<div class="paragraph"><p>If we look at the way commits are created under the cover, we&#8217;ll see
Junio C Hamanoba4b9282008-07-06 05:20:31971that there are more flexible ways creating commits.</p></div>
Junio C Hamano97bcb482010-11-25 03:16:07972<div class="paragraph"><p>Continuing with our test-project, let&#8217;s modify file.txt again:</p></div>
Junio C Hamanodfccbb02008-05-26 01:16:14973<div class="listingblock">
974<div class="content">
Junio C Hamano446e30b2014-10-16 21:30:32975<pre><code>$ echo "hello world, again" &gt;&gt;file.txt</code></pre>
Junio C Hamanodfccbb02008-05-26 01:16:14976</div></div>
Junio C Hamano97bcb482010-11-25 03:16:07977<div class="paragraph"><p>but this time instead of immediately making the commit, let&#8217;s take an
Junio C Hamanodfccbb02008-05-26 01:16:14978intermediate step, and ask for diffs along the way to keep track of
Junio C Hamano97bcb482010-11-25 03:16:07979what&#8217;s happening:</p></div>
Junio C Hamanodfccbb02008-05-26 01:16:14980<div class="listingblock">
981<div class="content">
Junio C Hamano446e30b2014-10-16 21:30:32982<pre><code>$ git diff
Junio C Hamanodfccbb02008-05-26 01:16:14983--- a/file.txt
984+++ b/file.txt
985@@ -1 +1,2 @@
986 hello world!
987+hello world, again
988$ git add file.txt
Junio C Hamano446e30b2014-10-16 21:30:32989$ git diff</code></pre>
Junio C Hamanodfccbb02008-05-26 01:16:14990</div></div>
Junio C Hamano97bcb482010-11-25 03:16:07991<div class="paragraph"><p>The last diff is empty, but no new commits have been made, and the
992head still doesn&#8217;t contain the new line:</p></div>
Junio C Hamanodfccbb02008-05-26 01:16:14993<div class="listingblock">
994<div class="content">
Junio C Hamano446e30b2014-10-16 21:30:32995<pre><code>$ git diff HEAD
Junio C Hamanodfccbb02008-05-26 01:16:14996diff --git a/file.txt b/file.txt
997index a042389..513feba 100644
998--- a/file.txt
999+++ b/file.txt
1000@@ -1 +1,2 @@
1001 hello world!
Junio C Hamano446e30b2014-10-16 21:30:321002+hello world, again</code></pre>
Junio C Hamanodfccbb02008-05-26 01:16:141003</div></div>
Junio C Hamano97bcb482010-11-25 03:16:071004<div class="paragraph"><p>So <em>git diff</em> is comparing against something other than the head.
1005The thing that it&#8217;s comparing against is actually the index file,
Junio C Hamanodfccbb02008-05-26 01:16:141006which is stored in .git/index in a binary format, but whose contents
Junio C Hamanoba4b9282008-07-06 05:20:311007we can examine with ls-files:</p></div>
Junio C Hamanodfccbb02008-05-26 01:16:141008<div class="listingblock">
1009<div class="content">
Junio C Hamano446e30b2014-10-16 21:30:321010<pre><code>$ git ls-files --stage
Junio C Hamanodfccbb02008-05-26 01:16:141011100644 513feba2e53ebbd2532419ded848ba19de88ba00 0 file.txt
1012$ git cat-file -t 513feba2
1013blob
1014$ git cat-file blob 513feba2
1015hello world!
Junio C Hamano446e30b2014-10-16 21:30:321016hello world, again</code></pre>
Junio C Hamanodfccbb02008-05-26 01:16:141017</div></div>
Junio C Hamano97bcb482010-11-25 03:16:071018<div class="paragraph"><p>So what our <em>git add</em> did was store a new blob and then put
Junio C Hamanodfccbb02008-05-26 01:16:141019a reference to it in the index file. If we modify the file again,
Junio C Hamano97bcb482010-11-25 03:16:071020we&#8217;ll see that the new modifications are reflected in the <em>git diff</em>
Junio C Hamanoba4b9282008-07-06 05:20:311021output:</p></div>
Junio C Hamanodfccbb02008-05-26 01:16:141022<div class="listingblock">
1023<div class="content">
Junio C Hamano446e30b2014-10-16 21:30:321024<pre><code>$ echo 'again?' &gt;&gt;file.txt
Junio C Hamanodfccbb02008-05-26 01:16:141025$ git diff
1026index 513feba..ba3da7b 100644
1027--- a/file.txt
1028+++ b/file.txt
1029@@ -1,2 +1,3 @@
1030 hello world!
1031 hello world, again
Junio C Hamano446e30b2014-10-16 21:30:321032+again?</code></pre>
Junio C Hamanodfccbb02008-05-26 01:16:141033</div></div>
Junio C Hamano97bcb482010-11-25 03:16:071034<div class="paragraph"><p>With the right arguments, <em>git diff</em> can also show us the difference
Junio C Hamanodfccbb02008-05-26 01:16:141035between the working directory and the last commit, or between the
Junio C Hamanoba4b9282008-07-06 05:20:311036index and the last commit:</p></div>
Junio C Hamanodfccbb02008-05-26 01:16:141037<div class="listingblock">
1038<div class="content">
Junio C Hamano446e30b2014-10-16 21:30:321039<pre><code>$ git diff HEAD
Junio C Hamanodfccbb02008-05-26 01:16:141040diff --git a/file.txt b/file.txt
1041index a042389..ba3da7b 100644
1042--- a/file.txt
1043+++ b/file.txt
1044@@ -1 +1,3 @@
1045 hello world!
1046+hello world, again
1047+again?
1048$ git diff --cached
1049diff --git a/file.txt b/file.txt
1050index a042389..513feba 100644
1051--- a/file.txt
1052+++ b/file.txt
1053@@ -1 +1,2 @@
1054 hello world!
Junio C Hamano446e30b2014-10-16 21:30:321055+hello world, again</code></pre>
Junio C Hamanodfccbb02008-05-26 01:16:141056</div></div>
Junio C Hamano97bcb482010-11-25 03:16:071057<div class="paragraph"><p>At any time, we can create a new commit using <em>git commit</em> (without
Junio C Hamanofce7c7e2008-07-02 03:06:381058the "-a" option), and verify that the state committed only includes the
Junio C Hamanodfccbb02008-05-26 01:16:141059changes stored in the index file, not the additional change that is
Junio C Hamanoba4b9282008-07-06 05:20:311060still only in our working tree:</p></div>
Junio C Hamanodfccbb02008-05-26 01:16:141061<div class="listingblock">
1062<div class="content">
Junio C Hamano446e30b2014-10-16 21:30:321063<pre><code>$ git commit -m "repeat"
Junio C Hamanodfccbb02008-05-26 01:16:141064$ git diff HEAD
1065diff --git a/file.txt b/file.txt
1066index 513feba..ba3da7b 100644
1067--- a/file.txt
1068+++ b/file.txt
1069@@ -1,2 +1,3 @@
1070 hello world!
1071 hello world, again
Junio C Hamano446e30b2014-10-16 21:30:321072+again?</code></pre>
Junio C Hamanodfccbb02008-05-26 01:16:141073</div></div>
Junio C Hamano97bcb482010-11-25 03:16:071074<div class="paragraph"><p>So by default <em>git commit</em> uses the index to create the commit, not
Junio C Hamanofce7c7e2008-07-02 03:06:381075the working tree; the "-a" option to commit tells it to first update
Junio C Hamanoba4b9282008-07-06 05:20:311076the index with all changes in the working tree.</p></div>
Junio C Hamano97bcb482010-11-25 03:16:071077<div class="paragraph"><p>Finally, it&#8217;s worth looking at the effect of <em>git add</em> on the index
Junio C Hamanoba4b9282008-07-06 05:20:311078file:</p></div>
Junio C Hamanodfccbb02008-05-26 01:16:141079<div class="listingblock">
1080<div class="content">
Junio C Hamano446e30b2014-10-16 21:30:321081<pre><code>$ echo "goodbye, world" &gt;closing.txt
1082$ git add closing.txt</code></pre>
Junio C Hamanodfccbb02008-05-26 01:16:141083</div></div>
Junio C Hamano97bcb482010-11-25 03:16:071084<div class="paragraph"><p>The effect of the <em>git add</em> was to add one entry to the index file:</p></div>
Junio C Hamanodfccbb02008-05-26 01:16:141085<div class="listingblock">
1086<div class="content">
Junio C Hamano446e30b2014-10-16 21:30:321087<pre><code>$ git ls-files --stage
Junio C Hamanodfccbb02008-05-26 01:16:141088100644 8b9743b20d4b15be3955fc8d5cd2b09cd2336138 0 closing.txt
Junio C Hamano446e30b2014-10-16 21:30:321089100644 513feba2e53ebbd2532419ded848ba19de88ba00 0 file.txt</code></pre>
Junio C Hamanodfccbb02008-05-26 01:16:141090</div></div>
Junio C Hamano97bcb482010-11-25 03:16:071091<div class="paragraph"><p>And, as you can see with cat-file, this new entry refers to the
Junio C Hamanoba4b9282008-07-06 05:20:311092current contents of the file:</p></div>
Junio C Hamanodfccbb02008-05-26 01:16:141093<div class="listingblock">
1094<div class="content">
Junio C Hamano446e30b2014-10-16 21:30:321095<pre><code>$ git cat-file blob 8b9743b2
1096goodbye, world</code></pre>
Junio C Hamanodfccbb02008-05-26 01:16:141097</div></div>
Junio C Hamano97bcb482010-11-25 03:16:071098<div class="paragraph"><p>The "status" command is a useful way to get a quick summary of the
Junio C Hamanoba4b9282008-07-06 05:20:311099situation:</p></div>
Junio C Hamanodfccbb02008-05-26 01:16:141100<div class="listingblock">
1101<div class="content">
Junio C Hamano446e30b2014-10-16 21:30:321102<pre><code>$ git status
Junio C Hamano13220242014-11-19 23:06:271103On branch master
1104Changes to be committed:
1105 (use "git reset HEAD &lt;file&gt;..." to unstage)
1106
1107 new file: closing.txt
1108
1109Changes not staged for commit:
1110 (use "git add &lt;file&gt;..." to update what will be committed)
1111 (use "git checkout -- &lt;file&gt;..." to discard changes in working directory)
1112
1113 modified: file.txt</code></pre>
Junio C Hamanodfccbb02008-05-26 01:16:141114</div></div>
Junio C Hamano97bcb482010-11-25 03:16:071115<div class="paragraph"><p>Since the current state of closing.txt is cached in the index file,
Junio C Hamanodfccbb02008-05-26 01:16:141116it is listed as "Changes to be committed". Since file.txt has
Junio C Hamano97bcb482010-11-25 03:16:071117changes in the working directory that aren&#8217;t reflected in the index,
Junio C Hamanodfccbb02008-05-26 01:16:141118it is marked "changed but not updated". At this point, running "git
1119commit" would create a commit that added closing.txt (with its new
Junio C Hamano97bcb482010-11-25 03:16:071120contents), but that didn&#8217;t modify file.txt.</p></div>
Junio C Hamano446e30b2014-10-16 21:30:321121<div class="paragraph"><p>Also, note that a bare <code>git diff</code> shows the changes to file.txt, but
Junio C Hamanodfccbb02008-05-26 01:16:141122not the addition of closing.txt, because the version of closing.txt
Junio C Hamanoba4b9282008-07-06 05:20:311123in the index file is identical to the one in the working directory.</p></div>
Junio C Hamano97bcb482010-11-25 03:16:071124<div class="paragraph"><p>In addition to being the staging area for new commits, the index file
Junio C Hamanodfccbb02008-05-26 01:16:141125is also populated from the object database when checking out a
1126branch, and is used to hold the trees involved in a merge operation.
Junio C Hamanoa28a9202012-06-21 07:08:231127See <a href="gitcore-tutorial.html">gitcore-tutorial(7)</a> and the relevant man
Junio C Hamanoba4b9282008-07-06 05:20:311128pages for details.</p></div>
Junio C Hamanodfccbb02008-05-26 01:16:141129</div>
Junio C Hamano9d971152012-12-19 00:43:111130</div>
1131<div class="sect1">
Junio C Hamanoba4b9282008-07-06 05:20:311132<h2 id="_what_next">What next?</h2>
Junio C Hamanodfccbb02008-05-26 01:16:141133<div class="sectionbody">
Junio C Hamano97bcb482010-11-25 03:16:071134<div class="paragraph"><p>At this point you should know everything necessary to read the man
Junio C Hamanodfccbb02008-05-26 01:16:141135pages for any of the git commands; one good place to start would be
Junio C Hamano446e30b2014-10-16 21:30:321136with the commands mentioned in <a href="giteveryday.html">giteveryday(7)</a>. You
Junio C Hamanoa28a9202012-06-21 07:08:231137should be able to find any unknown jargon in <a href="gitglossary.html">gitglossary(7)</a>.</p></div>
Junio C Hamano97bcb482010-11-25 03:16:071138<div class="paragraph"><p>The <a href="user-manual.html">Git User&#8217;s Manual</a> provides a more
Junio C Hamano076ffcc2013-02-06 05:13:211139comprehensive introduction to Git.</p></div>
Junio C Hamanoa28a9202012-06-21 07:08:231140<div class="paragraph"><p><a href="gitcvs-migration.html">gitcvs-migration(7)</a> explains how to
Junio C Hamano076ffcc2013-02-06 05:13:211141import a CVS repository into Git, and shows how to use Git in a
Junio C Hamanoba4b9282008-07-06 05:20:311142CVS-like way.</p></div>
Junio C Hamano076ffcc2013-02-06 05:13:211143<div class="paragraph"><p>For some interesting examples of Git use, see the
Junio C Hamanoba4b9282008-07-06 05:20:311144<a href="howto-index.html">howtos</a>.</p></div>
Junio C Hamano076ffcc2013-02-06 05:13:211145<div class="paragraph"><p>For Git developers, <a href="gitcore-tutorial.html">gitcore-tutorial(7)</a> goes
1146into detail on the lower-level Git mechanisms involved in, for
Junio C Hamanoba4b9282008-07-06 05:20:311147example, creating a new commit.</p></div>
Junio C Hamanodfccbb02008-05-26 01:16:141148</div>
Junio C Hamano9d971152012-12-19 00:43:111149</div>
1150<div class="sect1">
Junio C Hamanoba4b9282008-07-06 05:20:311151<h2 id="_see_also">SEE ALSO</h2>
Junio C Hamanodfccbb02008-05-26 01:16:141152<div class="sectionbody">
Junio C Hamanoa28a9202012-06-21 07:08:231153<div class="paragraph"><p><a href="gittutorial.html">gittutorial(7)</a>,
1154<a href="gitcvs-migration.html">gitcvs-migration(7)</a>,
1155<a href="gitcore-tutorial.html">gitcore-tutorial(7)</a>,
1156<a href="gitglossary.html">gitglossary(7)</a>,
1157<a href="git-help.html">git-help(1)</a>,
Junio C Hamano446e30b2014-10-16 21:30:321158<a href="giteveryday.html">giteveryday(7)</a>,
Junio C Hamano97bcb482010-11-25 03:16:071159<a href="user-manual.html">The Git User&#8217;s Manual</a></p></div>
Junio C Hamanodfccbb02008-05-26 01:16:141160</div>
Junio C Hamano9d971152012-12-19 00:43:111161</div>
1162<div class="sect1">
Junio C Hamanoba4b9282008-07-06 05:20:311163<h2 id="_git">GIT</h2>
Junio C Hamanodfccbb02008-05-26 01:16:141164<div class="sectionbody">
Junio C Hamanoe89102f2017-02-15 23:18:151165<div class="paragraph"><p>Part of the <a href="git.html">git(1)</a> suite</p></div>
Junio C Hamanodfccbb02008-05-26 01:16:141166</div>
Junio C Hamano7bd050f2011-09-22 06:32:221167</div>
Junio C Hamano9d971152012-12-19 00:43:111168</div>
Junio C Hamano7bd050f2011-09-22 06:32:221169<div id="footnotes"><hr /></div>
Junio C Hamanodfccbb02008-05-26 01:16:141170<div id="footer">
1171<div id="footer-text">
Junio C Hamano919d24f2017-05-09 14:51:221172Last updated 2017-02-16 08:17:51 JST
Junio C Hamanodfccbb02008-05-26 01:16:141173</div>
1174</div>
1175</body>
1176</html>