blob: 2f37ed6644be48fbb6a834a3a0e0b36304316181 [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(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(7) Manual Page
738</h1>
739<h2>NAME</h2>
740<div class="sectionbody">
741<p>gittutorial -
Junio C Hamano19a0f4e2014-11-18 21:46:36742 A tutorial introduction to Git
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 Hamano076ffcc2013-02-06 05:13:21759<div class="paragraph"><p>This tutorial explains how to import a new project into Git, make
Junio C Hamanoba4b9282008-07-06 05:20:31760changes to it, and share changes with other developers.</p></div>
Junio C Hamano076ffcc2013-02-06 05:13:21761<div class="paragraph"><p>If you are instead primarily interested in using Git to fetch a project,
Junio C Hamanodfccbb02008-05-26 01:16:14762for example, to test the latest version, you may prefer to start with
Junio C Hamano97bcb482010-11-25 03:16:07763the first two chapters of <a href="user-manual.html">The Git User&#8217;s Manual</a>.</p></div>
764<div class="paragraph"><p>First, note that you can get documentation for a command such as
Junio C Hamano446e30b2014-10-16 21:30:32765<code>git log --graph</code> with:</p></div>
Junio C Hamanodfccbb02008-05-26 01:16:14766<div class="listingblock">
767<div class="content">
Junio C Hamano446e30b2014-10-16 21:30:32768<pre><code>$ man git-log</code></pre>
Junio C Hamanodfccbb02008-05-26 01:16:14769</div></div>
Junio C Hamano97bcb482010-11-25 03:16:07770<div class="paragraph"><p>or:</p></div>
Junio C Hamanof66ecee2008-11-17 18:25:43771<div class="listingblock">
772<div class="content">
Junio C Hamano446e30b2014-10-16 21:30:32773<pre><code>$ git help log</code></pre>
Junio C Hamanof66ecee2008-11-17 18:25:43774</div></div>
Junio C Hamano97bcb482010-11-25 03:16:07775<div class="paragraph"><p>With the latter, you can use the manual viewer of your choice; see
Junio C Hamanoa28a9202012-06-21 07:08:23776<a href="git-help.html">git-help(1)</a> for more information.</p></div>
Junio C Hamano076ffcc2013-02-06 05:13:21777<div class="paragraph"><p>It is a good idea to introduce yourself to Git with your name and
Junio C Hamanodfccbb02008-05-26 01:16:14778public email address before doing any operation. The easiest
Junio C Hamanoba4b9282008-07-06 05:20:31779way to do so is:</p></div>
Junio C Hamanodfccbb02008-05-26 01:16:14780<div class="listingblock">
781<div class="content">
Junio C Hamano446e30b2014-10-16 21:30:32782<pre><code>$ git config --global user.name "Your Name Comes Here"
783$ git config --global user.email you@yourdomain.example.com</code></pre>
Junio C Hamanodfccbb02008-05-26 01:16:14784</div></div>
785</div>
Junio C Hamano9d971152012-12-19 00:43:11786</div>
787<div class="sect1">
Junio C Hamanoba4b9282008-07-06 05:20:31788<h2 id="_importing_a_new_project">Importing a new project</h2>
Junio C Hamanodfccbb02008-05-26 01:16:14789<div class="sectionbody">
Junio C Hamano97bcb482010-11-25 03:16:07790<div class="paragraph"><p>Assume you have a tarball project.tar.gz with your initial work. You
Junio C Hamano076ffcc2013-02-06 05:13:21791can place it under Git revision control as follows.</p></div>
Junio C Hamanodfccbb02008-05-26 01:16:14792<div class="listingblock">
793<div class="content">
Junio C Hamano446e30b2014-10-16 21:30:32794<pre><code>$ tar xzf project.tar.gz
Junio C Hamanodfccbb02008-05-26 01:16:14795$ cd project
Junio C Hamano446e30b2014-10-16 21:30:32796$ git init</code></pre>
Junio C Hamanodfccbb02008-05-26 01:16:14797</div></div>
Junio C Hamano97bcb482010-11-25 03:16:07798<div class="paragraph"><p>Git will reply</p></div>
Junio C Hamanodfccbb02008-05-26 01:16:14799<div class="listingblock">
800<div class="content">
Junio C Hamano446e30b2014-10-16 21:30:32801<pre><code>Initialized empty Git repository in .git/</code></pre>
Junio C Hamanodfccbb02008-05-26 01:16:14802</div></div>
Junio C Hamano97bcb482010-11-25 03:16:07803<div class="paragraph"><p>You&#8217;ve now initialized the working directory&#8212;you may notice a new
Junio C Hamanoba4b9282008-07-06 05:20:31804directory created, named ".git".</p></div>
Junio C Hamano076ffcc2013-02-06 05:13:21805<div class="paragraph"><p>Next, tell Git to take a snapshot of the contents of all files under the
Junio C Hamano1aa40d22010-01-21 17:46:43806current directory (note the <em>.</em>), with <em>git add</em>:</p></div>
Junio C Hamanodfccbb02008-05-26 01:16:14807<div class="listingblock">
808<div class="content">
Junio C Hamano446e30b2014-10-16 21:30:32809<pre><code>$ git add .</code></pre>
Junio C Hamanodfccbb02008-05-26 01:16:14810</div></div>
Junio C Hamano076ffcc2013-02-06 05:13:21811<div class="paragraph"><p>This snapshot is now stored in a temporary staging area which Git calls
Junio C Hamanodfccbb02008-05-26 01:16:14812the "index". You can permanently store the contents of the index in the
Junio C Hamano1aa40d22010-01-21 17:46:43813repository with <em>git commit</em>:</p></div>
Junio C Hamanodfccbb02008-05-26 01:16:14814<div class="listingblock">
815<div class="content">
Junio C Hamano446e30b2014-10-16 21:30:32816<pre><code>$ git commit</code></pre>
Junio C Hamanodfccbb02008-05-26 01:16:14817</div></div>
Junio C Hamano97bcb482010-11-25 03:16:07818<div class="paragraph"><p>This will prompt you for a commit message. You&#8217;ve now stored the first
Junio C Hamano076ffcc2013-02-06 05:13:21819version of your project in Git.</p></div>
Junio C Hamanodfccbb02008-05-26 01:16:14820</div>
Junio C Hamano9d971152012-12-19 00:43:11821</div>
822<div class="sect1">
Junio C Hamanoba4b9282008-07-06 05:20:31823<h2 id="_making_changes">Making changes</h2>
Junio C Hamanodfccbb02008-05-26 01:16:14824<div class="sectionbody">
Junio C Hamano97bcb482010-11-25 03:16:07825<div class="paragraph"><p>Modify some files, then add their updated contents to the index:</p></div>
Junio C Hamanodfccbb02008-05-26 01:16:14826<div class="listingblock">
827<div class="content">
Junio C Hamano446e30b2014-10-16 21:30:32828<pre><code>$ git add file1 file2 file3</code></pre>
Junio C Hamanodfccbb02008-05-26 01:16:14829</div></div>
Junio C Hamano97bcb482010-11-25 03:16:07830<div class="paragraph"><p>You are now ready to commit. You can see what is about to be committed
Junio C Hamano1aa40d22010-01-21 17:46:43831using <em>git diff</em> with the --cached option:</p></div>
Junio C Hamanodfccbb02008-05-26 01:16:14832<div class="listingblock">
833<div class="content">
Junio C Hamano446e30b2014-10-16 21:30:32834<pre><code>$ git diff --cached</code></pre>
Junio C Hamanodfccbb02008-05-26 01:16:14835</div></div>
Junio C Hamano97bcb482010-11-25 03:16:07836<div class="paragraph"><p>(Without --cached, <em>git diff</em> will show you any changes that
837you&#8217;ve made but not yet added to the index.) You can also get a brief
Junio C Hamano1aa40d22010-01-21 17:46:43838summary of the situation with <em>git status</em>:</p></div>
Junio C Hamanodfccbb02008-05-26 01:16:14839<div class="listingblock">
840<div class="content">
Junio C Hamano446e30b2014-10-16 21:30:32841<pre><code>$ git status
Junio C Hamano13220242014-11-19 23:06:27842On branch master
843Changes to be committed:
Junio C Hamano88bf5712017-09-10 08:39:23844Your branch is up to date with 'origin/master'.
Junio C Hamano13220242014-11-19 23:06:27845 (use "git reset HEAD &lt;file&gt;..." to unstage)
846
847 modified: file1
848 modified: file2
849 modified: file3</code></pre>
Junio C Hamanodfccbb02008-05-26 01:16:14850</div></div>
Junio C Hamano97bcb482010-11-25 03:16:07851<div class="paragraph"><p>If you need to make any further adjustments, do so now, and then add any
Junio C Hamanoba4b9282008-07-06 05:20:31852newly modified content to the index. Finally, commit your changes with:</p></div>
Junio C Hamanodfccbb02008-05-26 01:16:14853<div class="listingblock">
854<div class="content">
Junio C Hamano446e30b2014-10-16 21:30:32855<pre><code>$ git commit</code></pre>
Junio C Hamanodfccbb02008-05-26 01:16:14856</div></div>
Junio C Hamano97bcb482010-11-25 03:16:07857<div class="paragraph"><p>This will again prompt you for a message describing the change, and then
Junio C Hamanoba4b9282008-07-06 05:20:31858record a new version of the project.</p></div>
Junio C Hamano97bcb482010-11-25 03:16:07859<div class="paragraph"><p>Alternatively, instead of running <em>git add</em> beforehand, you can use</p></div>
Junio C Hamanodfccbb02008-05-26 01:16:14860<div class="listingblock">
861<div class="content">
Junio C Hamano446e30b2014-10-16 21:30:32862<pre><code>$ git commit -a</code></pre>
Junio C Hamanodfccbb02008-05-26 01:16:14863</div></div>
Junio C Hamano97bcb482010-11-25 03:16:07864<div class="paragraph"><p>which will automatically notice any modified (but not new) files, add
Junio C Hamanoba4b9282008-07-06 05:20:31865them to the index, and commit, all in one step.</p></div>
Junio C Hamano97bcb482010-11-25 03:16:07866<div class="paragraph"><p>A note on commit messages: Though not required, it&#8217;s a good idea to
Junio C Hamanodfccbb02008-05-26 01:16:14867begin the commit message with a single short (less than 50 character)
868line summarizing the change, followed by a blank line and then a more
Junio C Hamano281fd392012-09-17 23:57:41869thorough description. The text up to the first blank line in a commit
870message is treated as the commit title, and that title is used
Junio C Hamano076ffcc2013-02-06 05:13:21871throughout Git. For example, <a href="git-format-patch.html">git-format-patch(1)</a> turns a
Junio C Hamano281fd392012-09-17 23:57:41872commit into email, and it uses the title on the Subject line and the
873rest of the commit in the body.</p></div>
Junio C Hamanodfccbb02008-05-26 01:16:14874</div>
Junio C Hamano9d971152012-12-19 00:43:11875</div>
876<div class="sect1">
Junio C Hamanoba4b9282008-07-06 05:20:31877<h2 id="_git_tracks_content_not_files">Git tracks content not files</h2>
Junio C Hamanodfccbb02008-05-26 01:16:14878<div class="sectionbody">
Junio C Hamano446e30b2014-10-16 21:30:32879<div class="paragraph"><p>Many revision control systems provide an <code>add</code> command that tells the
880system to start tracking changes to a new file. Git&#8217;s <code>add</code> command
Junio C Hamano1aa40d22010-01-21 17:46:43881does something simpler and more powerful: <em>git add</em> is used both for new
Junio C Hamanodfccbb02008-05-26 01:16:14882and newly modified files, and in both cases it takes a snapshot of the
883given files and stages that content in the index, ready for inclusion in
Junio C Hamanoba4b9282008-07-06 05:20:31884the next commit.</p></div>
Junio C Hamanodfccbb02008-05-26 01:16:14885</div>
Junio C Hamano9d971152012-12-19 00:43:11886</div>
887<div class="sect1">
Junio C Hamanoba4b9282008-07-06 05:20:31888<h2 id="_viewing_project_history">Viewing project history</h2>
Junio C Hamanodfccbb02008-05-26 01:16:14889<div class="sectionbody">
Junio C Hamano97bcb482010-11-25 03:16:07890<div class="paragraph"><p>At any point you can view the history of your changes using</p></div>
Junio C Hamanodfccbb02008-05-26 01:16:14891<div class="listingblock">
892<div class="content">
Junio C Hamano446e30b2014-10-16 21:30:32893<pre><code>$ git log</code></pre>
Junio C Hamanodfccbb02008-05-26 01:16:14894</div></div>
Junio C Hamano97bcb482010-11-25 03:16:07895<div class="paragraph"><p>If you also want to see complete diffs at each step, use</p></div>
Junio C Hamanodfccbb02008-05-26 01:16:14896<div class="listingblock">
897<div class="content">
Junio C Hamano446e30b2014-10-16 21:30:32898<pre><code>$ git log -p</code></pre>
Junio C Hamanodfccbb02008-05-26 01:16:14899</div></div>
Junio C Hamano97bcb482010-11-25 03:16:07900<div class="paragraph"><p>Often the overview of the change is useful to get a feel of
Junio C Hamanoba4b9282008-07-06 05:20:31901each step</p></div>
Junio C Hamanodfccbb02008-05-26 01:16:14902<div class="listingblock">
903<div class="content">
Junio C Hamano446e30b2014-10-16 21:30:32904<pre><code>$ git log --stat --summary</code></pre>
Junio C Hamanodfccbb02008-05-26 01:16:14905</div></div>
906</div>
Junio C Hamano9d971152012-12-19 00:43:11907</div>
908<div class="sect1">
Junio C Hamanoba4b9282008-07-06 05:20:31909<h2 id="_managing_branches">Managing branches</h2>
Junio C Hamanodfccbb02008-05-26 01:16:14910<div class="sectionbody">
Junio C Hamano076ffcc2013-02-06 05:13:21911<div class="paragraph"><p>A single Git repository can maintain multiple branches of
Junio C Hamanoba4b9282008-07-06 05:20:31912development. To create a new branch named "experimental", use</p></div>
Junio C Hamanodfccbb02008-05-26 01:16:14913<div class="listingblock">
914<div class="content">
Junio C Hamano446e30b2014-10-16 21:30:32915<pre><code>$ git branch experimental</code></pre>
Junio C Hamanodfccbb02008-05-26 01:16:14916</div></div>
Junio C Hamano97bcb482010-11-25 03:16:07917<div class="paragraph"><p>If you now run</p></div>
Junio C Hamanodfccbb02008-05-26 01:16:14918<div class="listingblock">
919<div class="content">
Junio C Hamano446e30b2014-10-16 21:30:32920<pre><code>$ git branch</code></pre>
Junio C Hamanodfccbb02008-05-26 01:16:14921</div></div>
Junio C Hamano97bcb482010-11-25 03:16:07922<div class="paragraph"><p>you&#8217;ll get a list of all existing branches:</p></div>
Junio C Hamanodfccbb02008-05-26 01:16:14923<div class="listingblock">
924<div class="content">
Junio C Hamano446e30b2014-10-16 21:30:32925<pre><code> experimental
926* master</code></pre>
Junio C Hamanodfccbb02008-05-26 01:16:14927</div></div>
Junio C Hamano97bcb482010-11-25 03:16:07928<div class="paragraph"><p>The "experimental" branch is the one you just created, and the
Junio C Hamanodfccbb02008-05-26 01:16:14929"master" branch is a default branch that was created for you
930automatically. The asterisk marks the branch you are currently on;
Junio C Hamanoba4b9282008-07-06 05:20:31931type</p></div>
Junio C Hamanodfccbb02008-05-26 01:16:14932<div class="listingblock">
933<div class="content">
Junio C Hamano446e30b2014-10-16 21:30:32934<pre><code>$ git checkout experimental</code></pre>
Junio C Hamanodfccbb02008-05-26 01:16:14935</div></div>
Junio C Hamano97bcb482010-11-25 03:16:07936<div class="paragraph"><p>to switch to the experimental branch. Now edit a file, commit the
Junio C Hamanoba4b9282008-07-06 05:20:31937change, and switch back to the master branch:</p></div>
Junio C Hamanodfccbb02008-05-26 01:16:14938<div class="listingblock">
939<div class="content">
Junio C Hamano446e30b2014-10-16 21:30:32940<pre><code>(edit file)
Junio C Hamanodfccbb02008-05-26 01:16:14941$ git commit -a
Junio C Hamano446e30b2014-10-16 21:30:32942$ git checkout master</code></pre>
Junio C Hamanodfccbb02008-05-26 01:16:14943</div></div>
Junio C Hamano97bcb482010-11-25 03:16:07944<div class="paragraph"><p>Check that the change you made is no longer visible, since it was
945made on the experimental branch and you&#8217;re back on the master branch.</p></div>
946<div class="paragraph"><p>You can make a different change on the master branch:</p></div>
Junio C Hamanodfccbb02008-05-26 01:16:14947<div class="listingblock">
948<div class="content">
Junio C Hamano446e30b2014-10-16 21:30:32949<pre><code>(edit file)
950$ git commit -a</code></pre>
Junio C Hamanodfccbb02008-05-26 01:16:14951</div></div>
Junio C Hamano97bcb482010-11-25 03:16:07952<div class="paragraph"><p>at this point the two branches have diverged, with different changes
Junio C Hamanoba4b9282008-07-06 05:20:31953made in each. To merge the changes made in experimental into master, run</p></div>
Junio C Hamanodfccbb02008-05-26 01:16:14954<div class="listingblock">
955<div class="content">
Junio C Hamano446e30b2014-10-16 21:30:32956<pre><code>$ git merge experimental</code></pre>
Junio C Hamanodfccbb02008-05-26 01:16:14957</div></div>
Junio C Hamano97bcb482010-11-25 03:16:07958<div class="paragraph"><p>If the changes don&#8217;t conflict, you&#8217;re done. If there are conflicts,
Junio C Hamanoba4b9282008-07-06 05:20:31959markers will be left in the problematic files showing the conflict;</p></div>
Junio C Hamanodfccbb02008-05-26 01:16:14960<div class="listingblock">
961<div class="content">
Junio C Hamano446e30b2014-10-16 21:30:32962<pre><code>$ git diff</code></pre>
Junio C Hamanodfccbb02008-05-26 01:16:14963</div></div>
Junio C Hamano97bcb482010-11-25 03:16:07964<div class="paragraph"><p>will show this. Once you&#8217;ve edited the files to resolve the
Junio C Hamanoba4b9282008-07-06 05:20:31965conflicts,</p></div>
Junio C Hamanodfccbb02008-05-26 01:16:14966<div class="listingblock">
967<div class="content">
Junio C Hamano446e30b2014-10-16 21:30:32968<pre><code>$ git commit -a</code></pre>
Junio C Hamanodfccbb02008-05-26 01:16:14969</div></div>
Junio C Hamano97bcb482010-11-25 03:16:07970<div class="paragraph"><p>will commit the result of the merge. Finally,</p></div>
Junio C Hamanodfccbb02008-05-26 01:16:14971<div class="listingblock">
972<div class="content">
Junio C Hamano446e30b2014-10-16 21:30:32973<pre><code>$ gitk</code></pre>
Junio C Hamanodfccbb02008-05-26 01:16:14974</div></div>
Junio C Hamano97bcb482010-11-25 03:16:07975<div class="paragraph"><p>will show a nice graphical representation of the resulting history.</p></div>
976<div class="paragraph"><p>At this point you could delete the experimental branch with</p></div>
Junio C Hamanodfccbb02008-05-26 01:16:14977<div class="listingblock">
978<div class="content">
Junio C Hamano446e30b2014-10-16 21:30:32979<pre><code>$ git branch -d experimental</code></pre>
Junio C Hamanodfccbb02008-05-26 01:16:14980</div></div>
Junio C Hamano97bcb482010-11-25 03:16:07981<div class="paragraph"><p>This command ensures that the changes in the experimental branch are
Junio C Hamanoba4b9282008-07-06 05:20:31982already in the current branch.</p></div>
Junio C Hamano97bcb482010-11-25 03:16:07983<div class="paragraph"><p>If you develop on a branch crazy-idea, then regret it, you can always
Junio C Hamanoba4b9282008-07-06 05:20:31984delete the branch with</p></div>
Junio C Hamanodfccbb02008-05-26 01:16:14985<div class="listingblock">
986<div class="content">
Junio C Hamano446e30b2014-10-16 21:30:32987<pre><code>$ git branch -D crazy-idea</code></pre>
Junio C Hamanodfccbb02008-05-26 01:16:14988</div></div>
Junio C Hamano97bcb482010-11-25 03:16:07989<div class="paragraph"><p>Branches are cheap and easy, so this is a good way to try something
Junio C Hamanoba4b9282008-07-06 05:20:31990out.</p></div>
Junio C Hamanodfccbb02008-05-26 01:16:14991</div>
Junio C Hamano9d971152012-12-19 00:43:11992</div>
993<div class="sect1">
Junio C Hamano076ffcc2013-02-06 05:13:21994<h2 id="_using_git_for_collaboration">Using Git for collaboration</h2>
Junio C Hamanodfccbb02008-05-26 01:16:14995<div class="sectionbody">
Junio C Hamano076ffcc2013-02-06 05:13:21996<div class="paragraph"><p>Suppose that Alice has started a new project with a Git repository in
Junio C Hamanodfccbb02008-05-26 01:16:14997/home/alice/project, and that Bob, who has a home directory on the
Junio C Hamanoba4b9282008-07-06 05:20:31998same machine, wants to contribute.</p></div>
Junio C Hamano97bcb482010-11-25 03:16:07999<div class="paragraph"><p>Bob begins with:</p></div>
Junio C Hamanodfccbb02008-05-26 01:16:141000<div class="listingblock">
1001<div class="content">
Junio C Hamano446e30b2014-10-16 21:30:321002<pre><code>bob$ git clone /home/alice/project myrepo</code></pre>
Junio C Hamanodfccbb02008-05-26 01:16:141003</div></div>
Junio C Hamano97bcb482010-11-25 03:16:071004<div class="paragraph"><p>This creates a new directory "myrepo" containing a clone of Alice&#8217;s
Junio C Hamanodfccbb02008-05-26 01:16:141005repository. The clone is on an equal footing with the original
Junio C Hamano97bcb482010-11-25 03:16:071006project, possessing its own copy of the original project&#8217;s history.</p></div>
1007<div class="paragraph"><p>Bob then makes some changes and commits them:</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>(edit files)
Junio C Hamano38ddcce2008-07-15 15:49:031011bob$ git commit -a
Junio C Hamano446e30b2014-10-16 21:30:321012(repeat as necessary)</code></pre>
Junio C Hamanodfccbb02008-05-26 01:16:141013</div></div>
Junio C Hamano97bcb482010-11-25 03:16:071014<div class="paragraph"><p>When he&#8217;s ready, he tells Alice to pull changes from the repository
Junio C Hamanoba4b9282008-07-06 05:20:311015at /home/bob/myrepo. She does this with:</p></div>
Junio C Hamanodfccbb02008-05-26 01:16:141016<div class="listingblock">
1017<div class="content">
Junio C Hamano446e30b2014-10-16 21:30:321018<pre><code>alice$ cd /home/alice/project
1019alice$ git pull /home/bob/myrepo master</code></pre>
Junio C Hamanodfccbb02008-05-26 01:16:141020</div></div>
Junio C Hamano97bcb482010-11-25 03:16:071021<div class="paragraph"><p>This merges the changes from Bob&#8217;s "master" branch into Alice&#8217;s
Junio C Hamanodfccbb02008-05-26 01:16:141022current branch. If Alice has made her own changes in the meantime,
Junio C Hamano20d47e32009-01-26 06:36:021023then she may need to manually fix any conflicts.</p></div>
Junio C Hamano97bcb482010-11-25 03:16:071024<div class="paragraph"><p>The "pull" command thus performs two operations: it fetches changes
Junio C Hamanoba4b9282008-07-06 05:20:311025from a remote branch, then merges them into the current branch.</p></div>
Junio C Hamano97bcb482010-11-25 03:16:071026<div class="paragraph"><p>Note that in general, Alice would want her local changes committed before
1027initiating this "pull". If Bob&#8217;s work conflicts with what Alice did since
Junio C Hamano38ddcce2008-07-15 15:49:031028their histories forked, Alice will use her working tree and the index to
1029resolve conflicts, and existing local changes will interfere with the
Junio C Hamano076ffcc2013-02-06 05:13:211030conflict resolution process (Git will still perform the fetch but will
Junio C Hamano38ddcce2008-07-15 15:49:031031refuse to merge --- Alice will have to get rid of her local changes in
1032some way and pull again when this happens).</p></div>
Junio C Hamano97bcb482010-11-25 03:16:071033<div class="paragraph"><p>Alice can peek at what Bob did without merging first, using the "fetch"
Junio C Hamano38ddcce2008-07-15 15:49:031034command; this allows Alice to inspect what Bob did, using a special
1035symbol "FETCH_HEAD", in order to determine if he has anything worth
1036pulling, like this:</p></div>
1037<div class="listingblock">
1038<div class="content">
Junio C Hamano446e30b2014-10-16 21:30:321039<pre><code>alice$ git fetch /home/bob/myrepo master
1040alice$ git log -p HEAD..FETCH_HEAD</code></pre>
Junio C Hamano38ddcce2008-07-15 15:49:031041</div></div>
Junio C Hamano97bcb482010-11-25 03:16:071042<div class="paragraph"><p>This operation is safe even if Alice has uncommitted local changes.
Junio C Hamano73d812c2009-07-01 02:33:061043The range notation "HEAD..FETCH_HEAD" means "show everything that is reachable
1044from the FETCH_HEAD but exclude anything that is reachable from HEAD".
Junio C Hamanoa387df32008-08-29 08:56:581045Alice already knows everything that leads to her current state (HEAD),
Junio C Hamano73d812c2009-07-01 02:33:061046and reviews what Bob has in his state (FETCH_HEAD) that she has not
1047seen with this command.</p></div>
Junio C Hamano97bcb482010-11-25 03:16:071048<div class="paragraph"><p>If Alice wants to visualize what Bob did since their histories forked
Junio C Hamanoa387df32008-08-29 08:56:581049she can issue the following command:</p></div>
1050<div class="listingblock">
1051<div class="content">
Junio C Hamano446e30b2014-10-16 21:30:321052<pre><code>$ gitk HEAD..FETCH_HEAD</code></pre>
Junio C Hamanoa387df32008-08-29 08:56:581053</div></div>
Junio C Hamano97bcb482010-11-25 03:16:071054<div class="paragraph"><p>This uses the same two-dot range notation we saw earlier with <em>git log</em>.</p></div>
1055<div class="paragraph"><p>Alice may want to view what both of them did since they forked.
Junio C Hamanoa387df32008-08-29 08:56:581056She can use three-dot form instead of the two-dot form:</p></div>
1057<div class="listingblock">
1058<div class="content">
Junio C Hamano446e30b2014-10-16 21:30:321059<pre><code>$ gitk HEAD...FETCH_HEAD</code></pre>
Junio C Hamanoa387df32008-08-29 08:56:581060</div></div>
Junio C Hamano97bcb482010-11-25 03:16:071061<div class="paragraph"><p>This means "show everything that is reachable from either one, but
Junio C Hamanoa387df32008-08-29 08:56:581062exclude anything that is reachable from both of them".</p></div>
Junio C Hamano97bcb482010-11-25 03:16:071063<div class="paragraph"><p>Please note that these range notation can be used with both gitk
Junio C Hamanoa387df32008-08-29 08:56:581064and "git log".</p></div>
Junio C Hamano97bcb482010-11-25 03:16:071065<div class="paragraph"><p>After inspecting what Bob did, if there is nothing urgent, Alice may
1066decide to continue working without pulling from Bob. If Bob&#8217;s history
Junio C Hamano38ddcce2008-07-15 15:49:031067does have something Alice would immediately need, Alice may choose to
1068stash her work-in-progress first, do a "pull", and then finally unstash
1069her work-in-progress on top of the resulting history.</p></div>
Junio C Hamano97bcb482010-11-25 03:16:071070<div class="paragraph"><p>When you are working in a small closely knit group, it is not
Junio C Hamanodfccbb02008-05-26 01:16:141071unusual to interact with the same repository over and over
1072again. By defining <em>remote</em> repository shorthand, you can make
Junio C Hamanoba4b9282008-07-06 05:20:311073it easier:</p></div>
Junio C Hamanodfccbb02008-05-26 01:16:141074<div class="listingblock">
1075<div class="content">
Junio C Hamano446e30b2014-10-16 21:30:321076<pre><code>alice$ git remote add bob /home/bob/myrepo</code></pre>
Junio C Hamanodfccbb02008-05-26 01:16:141077</div></div>
Junio C Hamano97bcb482010-11-25 03:16:071078<div class="paragraph"><p>With this, Alice can perform the first part of the "pull" operation
Junio C Hamano1aa40d22010-01-21 17:46:431079alone using the <em>git fetch</em> command without merging them with her own
Junio C Hamano73d812c2009-07-01 02:33:061080branch, using:</p></div>
Junio C Hamanodfccbb02008-05-26 01:16:141081<div class="listingblock">
1082<div class="content">
Junio C Hamano446e30b2014-10-16 21:30:321083<pre><code>alice$ git fetch bob</code></pre>
Junio C Hamanodfccbb02008-05-26 01:16:141084</div></div>
Junio C Hamano97bcb482010-11-25 03:16:071085<div class="paragraph"><p>Unlike the longhand form, when Alice fetches from Bob using a
Junio C Hamano1aa40d22010-01-21 17:46:431086remote repository shorthand set up with <em>git remote</em>, what was
Junio C Hamano97bcb482010-11-25 03:16:071087fetched is stored in a remote-tracking branch, in this case
Junio C Hamano446e30b2014-10-16 21:30:321088<code>bob/master</code>. So after this:</p></div>
Junio C Hamanodfccbb02008-05-26 01:16:141089<div class="listingblock">
1090<div class="content">
Junio C Hamano446e30b2014-10-16 21:30:321091<pre><code>alice$ git log -p master..bob/master</code></pre>
Junio C Hamanodfccbb02008-05-26 01:16:141092</div></div>
Junio C Hamano97bcb482010-11-25 03:16:071093<div class="paragraph"><p>shows a list of all the changes that Bob made since he branched from
1094Alice&#8217;s master branch.</p></div>
1095<div class="paragraph"><p>After examining those changes, Alice
Junio C Hamanoba4b9282008-07-06 05:20:311096could merge the changes into her master branch:</p></div>
Junio C Hamanodfccbb02008-05-26 01:16:141097<div class="listingblock">
1098<div class="content">
Junio C Hamano446e30b2014-10-16 21:30:321099<pre><code>alice$ git merge bob/master</code></pre>
Junio C Hamanodfccbb02008-05-26 01:16:141100</div></div>
Junio C Hamano446e30b2014-10-16 21:30:321101<div class="paragraph"><p>This <code>merge</code> can also be done by <em>pulling from her own remote-tracking
Junio C Hamano97bcb482010-11-25 03:16:071102branch</em>, like this:</p></div>
Junio C Hamanodfccbb02008-05-26 01:16:141103<div class="listingblock">
1104<div class="content">
Junio C Hamano446e30b2014-10-16 21:30:321105<pre><code>alice$ git pull . remotes/bob/master</code></pre>
Junio C Hamanodfccbb02008-05-26 01:16:141106</div></div>
Junio C Hamano97bcb482010-11-25 03:16:071107<div class="paragraph"><p>Note that git pull always merges into the current branch,
Junio C Hamanoba4b9282008-07-06 05:20:311108regardless of what else is given on the command line.</p></div>
Junio C Hamano97bcb482010-11-25 03:16:071109<div class="paragraph"><p>Later, Bob can update his repo with Alice&#8217;s latest changes using</p></div>
Junio C Hamanodfccbb02008-05-26 01:16:141110<div class="listingblock">
1111<div class="content">
Junio C Hamano446e30b2014-10-16 21:30:321112<pre><code>bob$ git pull</code></pre>
Junio C Hamanodfccbb02008-05-26 01:16:141113</div></div>
Junio C Hamano97bcb482010-11-25 03:16:071114<div class="paragraph"><p>Note that he doesn&#8217;t need to give the path to Alice&#8217;s repository;
Junio C Hamano076ffcc2013-02-06 05:13:211115when Bob cloned Alice&#8217;s repository, Git stored the location of her
Junio C Hamanodfccbb02008-05-26 01:16:141116repository in the repository configuration, and that location is
Junio C Hamanoba4b9282008-07-06 05:20:311117used for pulls:</p></div>
Junio C Hamanodfccbb02008-05-26 01:16:141118<div class="listingblock">
1119<div class="content">
Junio C Hamano446e30b2014-10-16 21:30:321120<pre><code>bob$ git config --get remote.origin.url
1121/home/alice/project</code></pre>
Junio C Hamanodfccbb02008-05-26 01:16:141122</div></div>
Junio C Hamano97bcb482010-11-25 03:16:071123<div class="paragraph"><p>(The complete configuration created by <em>git clone</em> is visible using
Junio C Hamano446e30b2014-10-16 21:30:321124<code>git config -l</code>, and the <a href="git-config.html">git-config(1)</a> man page
Junio C Hamanoba4b9282008-07-06 05:20:311125explains the meaning of each option.)</p></div>
Junio C Hamano97bcb482010-11-25 03:16:071126<div class="paragraph"><p>Git also keeps a pristine copy of Alice&#8217;s master branch under the
Junio C Hamanoba4b9282008-07-06 05:20:311127name "origin/master":</p></div>
Junio C Hamanodfccbb02008-05-26 01:16:141128<div class="listingblock">
1129<div class="content">
Junio C Hamano446e30b2014-10-16 21:30:321130<pre><code>bob$ git branch -r
1131 origin/master</code></pre>
Junio C Hamanodfccbb02008-05-26 01:16:141132</div></div>
Junio C Hamano97bcb482010-11-25 03:16:071133<div class="paragraph"><p>If Bob later decides to work from a different host, he can still
Junio C Hamanoba4b9282008-07-06 05:20:311134perform clones and pulls using the ssh protocol:</p></div>
Junio C Hamanodfccbb02008-05-26 01:16:141135<div class="listingblock">
1136<div class="content">
Junio C Hamano446e30b2014-10-16 21:30:321137<pre><code>bob$ git clone alice.org:/home/alice/project myrepo</code></pre>
Junio C Hamanodfccbb02008-05-26 01:16:141138</div></div>
Junio C Hamanof85ef632016-02-17 22:31:061139<div class="paragraph"><p>Alternatively, Git has a native protocol, or can use http;
Junio C Hamanoa28a9202012-06-21 07:08:231140see <a href="git-pull.html">git-pull(1)</a> for details.</p></div>
Junio C Hamano97bcb482010-11-25 03:16:071141<div class="paragraph"><p>Git can also be used in a CVS-like mode, with a central repository
Junio C Hamanoa28a9202012-06-21 07:08:231142that various users push changes to; see <a href="git-push.html">git-push(1)</a> and
1143<a href="gitcvs-migration.html">gitcvs-migration(7)</a>.</p></div>
Junio C Hamanodfccbb02008-05-26 01:16:141144</div>
Junio C Hamano9d971152012-12-19 00:43:111145</div>
1146<div class="sect1">
Junio C Hamanoba4b9282008-07-06 05:20:311147<h2 id="_exploring_history">Exploring history</h2>
Junio C Hamanodfccbb02008-05-26 01:16:141148<div class="sectionbody">
Junio C Hamano97bcb482010-11-25 03:16:071149<div class="paragraph"><p>Git history is represented as a series of interrelated commits. We
Junio C Hamano1aa40d22010-01-21 17:46:431150have already seen that the <em>git log</em> command can list those commits.
Junio C Hamanodfccbb02008-05-26 01:16:141151Note that first line of each git log entry also gives a name for the
Junio C Hamanoba4b9282008-07-06 05:20:311152commit:</p></div>
Junio C Hamanodfccbb02008-05-26 01:16:141153<div class="listingblock">
1154<div class="content">
Junio C Hamano446e30b2014-10-16 21:30:321155<pre><code>$ git log
Junio C Hamanodfccbb02008-05-26 01:16:141156commit c82a22c39cbc32576f64f5c6b3f24b99ea8149c7
1157Author: Junio C Hamano &lt;junkio@cox.net&gt;
1158Date: Tue May 16 17:18:22 2006 -0700
1159
Junio C Hamano446e30b2014-10-16 21:30:321160 merge-base: Clarify the comments on post processing.</code></pre>
Junio C Hamanodfccbb02008-05-26 01:16:141161</div></div>
Junio C Hamano97bcb482010-11-25 03:16:071162<div class="paragraph"><p>We can give this name to <em>git show</em> to see the details about this
Junio C Hamanoba4b9282008-07-06 05:20:311163commit.</p></div>
Junio C Hamanodfccbb02008-05-26 01:16:141164<div class="listingblock">
1165<div class="content">
Junio C Hamano446e30b2014-10-16 21:30:321166<pre><code>$ git show c82a22c39cbc32576f64f5c6b3f24b99ea8149c7</code></pre>
Junio C Hamanodfccbb02008-05-26 01:16:141167</div></div>
Junio C Hamano97bcb482010-11-25 03:16:071168<div class="paragraph"><p>But there are other ways to refer to commits. You can use any initial
Junio C Hamanoba4b9282008-07-06 05:20:311169part of the name that is long enough to uniquely identify the commit:</p></div>
Junio C Hamanodfccbb02008-05-26 01:16:141170<div class="listingblock">
1171<div class="content">
Junio C Hamano446e30b2014-10-16 21:30:321172<pre><code>$ git show c82a22c39c # the first few characters of the name are
Junio C Hamanodfccbb02008-05-26 01:16:141173 # usually enough
1174$ git show HEAD # the tip of the current branch
Junio C Hamano446e30b2014-10-16 21:30:321175$ git show experimental # the tip of the "experimental" branch</code></pre>
Junio C Hamanodfccbb02008-05-26 01:16:141176</div></div>
Junio C Hamano97bcb482010-11-25 03:16:071177<div class="paragraph"><p>Every commit usually has one "parent" commit
Junio C Hamanoba4b9282008-07-06 05:20:311178which points to the previous state of the project:</p></div>
Junio C Hamanodfccbb02008-05-26 01:16:141179<div class="listingblock">
1180<div class="content">
Junio C Hamano446e30b2014-10-16 21:30:321181<pre><code>$ git show HEAD^ # to see the parent of HEAD
Junio C Hamanodfccbb02008-05-26 01:16:141182$ git show HEAD^^ # to see the grandparent of HEAD
Junio C Hamano446e30b2014-10-16 21:30:321183$ git show HEAD~4 # to see the great-great grandparent of HEAD</code></pre>
Junio C Hamanodfccbb02008-05-26 01:16:141184</div></div>
Junio C Hamano97bcb482010-11-25 03:16:071185<div class="paragraph"><p>Note that merge commits may have more than one parent:</p></div>
Junio C Hamanodfccbb02008-05-26 01:16:141186<div class="listingblock">
1187<div class="content">
Junio C Hamano446e30b2014-10-16 21:30:321188<pre><code>$ git show HEAD^1 # show the first parent of HEAD (same as HEAD^)
1189$ git show HEAD^2 # show the second parent of HEAD</code></pre>
Junio C Hamanodfccbb02008-05-26 01:16:141190</div></div>
Junio C Hamano97bcb482010-11-25 03:16:071191<div class="paragraph"><p>You can also give commits names of your own; after running</p></div>
Junio C Hamanodfccbb02008-05-26 01:16:141192<div class="listingblock">
1193<div class="content">
Junio C Hamano446e30b2014-10-16 21:30:321194<pre><code>$ git tag v2.5 1b2e1d63ff</code></pre>
Junio C Hamanodfccbb02008-05-26 01:16:141195</div></div>
Junio C Hamano97bcb482010-11-25 03:16:071196<div class="paragraph"><p>you can refer to 1b2e1d63ff by the name "v2.5". If you intend to
Junio C Hamanodfccbb02008-05-26 01:16:141197share this name with other people (for example, to identify a release
1198version), you should create a "tag" object, and perhaps sign it; see
Junio C Hamanoa28a9202012-06-21 07:08:231199<a href="git-tag.html">git-tag(1)</a> for details.</p></div>
Junio C Hamano076ffcc2013-02-06 05:13:211200<div class="paragraph"><p>Any Git command that needs to know a commit can take any of these
Junio C Hamanoba4b9282008-07-06 05:20:311201names. For example:</p></div>
Junio C Hamanodfccbb02008-05-26 01:16:141202<div class="listingblock">
1203<div class="content">
Junio C Hamano446e30b2014-10-16 21:30:321204<pre><code>$ git diff v2.5 HEAD # compare the current HEAD to v2.5
Junio C Hamanodfccbb02008-05-26 01:16:141205$ git branch stable v2.5 # start a new branch named "stable" based
1206 # at v2.5
1207$ git reset --hard HEAD^ # reset your current branch and working
Junio C Hamano446e30b2014-10-16 21:30:321208 # directory to its state at HEAD^</code></pre>
Junio C Hamanodfccbb02008-05-26 01:16:141209</div></div>
Junio C Hamano97bcb482010-11-25 03:16:071210<div class="paragraph"><p>Be careful with that last command: in addition to losing any changes
Junio C Hamanodfccbb02008-05-26 01:16:141211in the working directory, it will also remove all later commits from
1212this branch. If this branch is the only branch containing those
Junio C Hamano97bcb482010-11-25 03:16:071213commits, they will be lost. Also, don&#8217;t use <em>git reset</em> on a
Junio C Hamanodfccbb02008-05-26 01:16:141214publicly-visible branch that other developers pull from, as it will
1215force needless merges on other developers to clean up the history.
Junio C Hamano1aa40d22010-01-21 17:46:431216If you need to undo changes that you have pushed, use <em>git revert</em>
Junio C Hamanoba4b9282008-07-06 05:20:311217instead.</p></div>
Junio C Hamano97bcb482010-11-25 03:16:071218<div class="paragraph"><p>The <em>git grep</em> command can search for strings in any version of your
Junio C Hamanoba4b9282008-07-06 05:20:311219project, so</p></div>
Junio C Hamanodfccbb02008-05-26 01:16:141220<div class="listingblock">
1221<div class="content">
Junio C Hamano446e30b2014-10-16 21:30:321222<pre><code>$ git grep "hello" v2.5</code></pre>
Junio C Hamanodfccbb02008-05-26 01:16:141223</div></div>
Junio C Hamano97bcb482010-11-25 03:16:071224<div class="paragraph"><p>searches for all occurrences of "hello" in v2.5.</p></div>
1225<div class="paragraph"><p>If you leave out the commit name, <em>git grep</em> will search any of the
Junio C Hamanoba4b9282008-07-06 05:20:311226files it manages in your current directory. So</p></div>
Junio C Hamanodfccbb02008-05-26 01:16:141227<div class="listingblock">
1228<div class="content">
Junio C Hamano446e30b2014-10-16 21:30:321229<pre><code>$ git grep "hello"</code></pre>
Junio C Hamanodfccbb02008-05-26 01:16:141230</div></div>
Junio C Hamano076ffcc2013-02-06 05:13:211231<div class="paragraph"><p>is a quick way to search just the files that are tracked by Git.</p></div>
1232<div class="paragraph"><p>Many Git commands also take sets of commits, which can be specified
Junio C Hamano1aa40d22010-01-21 17:46:431233in a number of ways. Here are some examples with <em>git log</em>:</p></div>
Junio C Hamanodfccbb02008-05-26 01:16:141234<div class="listingblock">
1235<div class="content">
Junio C Hamano446e30b2014-10-16 21:30:321236<pre><code>$ git log v2.5..v2.6 # commits between v2.5 and v2.6
Junio C Hamanodfccbb02008-05-26 01:16:141237$ git log v2.5.. # commits since v2.5
1238$ git log --since="2 weeks ago" # commits from the last 2 weeks
1239$ git log v2.5.. Makefile # commits since v2.5 which modify
Junio C Hamano446e30b2014-10-16 21:30:321240 # Makefile</code></pre>
Junio C Hamanodfccbb02008-05-26 01:16:141241</div></div>
Junio C Hamano97bcb482010-11-25 03:16:071242<div class="paragraph"><p>You can also give <em>git log</em> a "range" of commits where the first is not
Junio C Hamanodfccbb02008-05-26 01:16:141243necessarily an ancestor of the second; for example, if the tips of
Junio C Hamano73d812c2009-07-01 02:33:061244the branches "stable" and "master" diverged from a common
Junio C Hamanoba4b9282008-07-06 05:20:311245commit some time ago, then</p></div>
Junio C Hamanodfccbb02008-05-26 01:16:141246<div class="listingblock">
1247<div class="content">
Junio C Hamano446e30b2014-10-16 21:30:321248<pre><code>$ git log stable..master</code></pre>
Junio C Hamanodfccbb02008-05-26 01:16:141249</div></div>
Junio C Hamano97bcb482010-11-25 03:16:071250<div class="paragraph"><p>will list commits made in the master branch but not in the
Junio C Hamanoba4b9282008-07-06 05:20:311251stable branch, while</p></div>
Junio C Hamanodfccbb02008-05-26 01:16:141252<div class="listingblock">
1253<div class="content">
Junio C Hamano446e30b2014-10-16 21:30:321254<pre><code>$ git log master..stable</code></pre>
Junio C Hamanodfccbb02008-05-26 01:16:141255</div></div>
Junio C Hamano97bcb482010-11-25 03:16:071256<div class="paragraph"><p>will show the list of commits made on the stable branch but not
Junio C Hamano73d812c2009-07-01 02:33:061257the master branch.</p></div>
Junio C Hamano97bcb482010-11-25 03:16:071258<div class="paragraph"><p>The <em>git log</em> command has a weakness: it must present commits in a
Junio C Hamanodfccbb02008-05-26 01:16:141259list. When the history has lines of development that diverged and
Junio C Hamano1aa40d22010-01-21 17:46:431260then merged back together, the order in which <em>git log</em> presents
Junio C Hamanoba4b9282008-07-06 05:20:311261those commits is meaningless.</p></div>
Junio C Hamano97bcb482010-11-25 03:16:071262<div class="paragraph"><p>Most projects with multiple contributors (such as the Linux kernel,
Junio C Hamano076ffcc2013-02-06 05:13:211263or Git itself) have frequent merges, and <em>gitk</em> does a better job of
Junio C Hamanoba4b9282008-07-06 05:20:311264visualizing their history. For example,</p></div>
Junio C Hamanodfccbb02008-05-26 01:16:141265<div class="listingblock">
1266<div class="content">
Junio C Hamano446e30b2014-10-16 21:30:321267<pre><code>$ gitk --since="2 weeks ago" drivers/</code></pre>
Junio C Hamanodfccbb02008-05-26 01:16:141268</div></div>
Junio C Hamano97bcb482010-11-25 03:16:071269<div class="paragraph"><p>allows you to browse any commits from the last 2 weeks of commits
Junio C Hamanodfccbb02008-05-26 01:16:141270that modified files under the "drivers" directory. (Note: you can
Junio C Hamano97bcb482010-11-25 03:16:071271adjust gitk&#8217;s fonts by holding down the control key while pressing
Junio C Hamanoba4b9282008-07-06 05:20:311272"-" or "+".)</p></div>
Junio C Hamano97bcb482010-11-25 03:16:071273<div class="paragraph"><p>Finally, most commands that take filenames will optionally allow you
Junio C Hamanodfccbb02008-05-26 01:16:141274to precede any filename by a commit, to specify a particular version
Junio C Hamanoba4b9282008-07-06 05:20:311275of the file:</p></div>
Junio C Hamanodfccbb02008-05-26 01:16:141276<div class="listingblock">
1277<div class="content">
Junio C Hamano446e30b2014-10-16 21:30:321278<pre><code>$ git diff v2.5:Makefile HEAD:Makefile.in</code></pre>
Junio C Hamanodfccbb02008-05-26 01:16:141279</div></div>
Junio C Hamano97bcb482010-11-25 03:16:071280<div class="paragraph"><p>You can also use <em>git show</em> to see any such file:</p></div>
Junio C Hamanodfccbb02008-05-26 01:16:141281<div class="listingblock">
1282<div class="content">
Junio C Hamano446e30b2014-10-16 21:30:321283<pre><code>$ git show v2.5:Makefile</code></pre>
Junio C Hamanodfccbb02008-05-26 01:16:141284</div></div>
1285</div>
Junio C Hamano9d971152012-12-19 00:43:111286</div>
1287<div class="sect1">
Junio C Hamanoba4b9282008-07-06 05:20:311288<h2 id="_next_steps">Next Steps</h2>
Junio C Hamanodfccbb02008-05-26 01:16:141289<div class="sectionbody">
Junio C Hamano97bcb482010-11-25 03:16:071290<div class="paragraph"><p>This tutorial should be enough to perform basic distributed revision
Junio C Hamanodfccbb02008-05-26 01:16:141291control for your projects. However, to fully understand the depth
Junio C Hamano076ffcc2013-02-06 05:13:211292and power of Git you need to understand two simple ideas on which it
Junio C Hamanoba4b9282008-07-06 05:20:311293is based:</p></div>
Junio C Hamano97bcb482010-11-25 03:16:071294<div class="ulist"><ul>
Junio C Hamanodfccbb02008-05-26 01:16:141295<li>
1296<p>
1297The object database is the rather elegant system used to
Junio C Hamano97bcb482010-11-25 03:16:071298 store the history of your project&#8212;files, directories, and
Junio C Hamanodfccbb02008-05-26 01:16:141299 commits.
1300</p>
1301</li>
1302<li>
1303<p>
1304The index file is a cache of the state of a directory tree,
1305 used to create commits, check out working directories, and
1306 hold the various trees involved in a merge.
1307</p>
1308</li>
Junio C Hamanoba4b9282008-07-06 05:20:311309</ul></div>
Junio C Hamano97bcb482010-11-25 03:16:071310<div class="paragraph"><p>Part two of this tutorial explains the object
1311database, the index file, and a few other odds and ends that you&#8217;ll
Junio C Hamano076ffcc2013-02-06 05:13:211312need to make the most of Git. You can find it at <a href="gittutorial-2.html">gittutorial-2(7)</a>.</p></div>
Junio C Hamano97bcb482010-11-25 03:16:071313<div class="paragraph"><p>If you don&#8217;t want to continue with that right away, a few other
Junio C Hamanoba4b9282008-07-06 05:20:311314digressions that may be interesting at this point are:</p></div>
Junio C Hamano97bcb482010-11-25 03:16:071315<div class="ulist"><ul>
Junio C Hamanodfccbb02008-05-26 01:16:141316<li>
1317<p>
Junio C Hamanoa28a9202012-06-21 07:08:231318<a href="git-format-patch.html">git-format-patch(1)</a>, <a href="git-am.html">git-am(1)</a>: These convert
Junio C Hamanodfccbb02008-05-26 01:16:141319 series of git commits into emailed patches, and vice versa,
Junio C Hamano4fbdd442009-01-06 05:56:241320 useful for projects such as the Linux kernel which rely heavily
Junio C Hamanodfccbb02008-05-26 01:16:141321 on emailed patches.
1322</p>
1323</li>
1324<li>
1325<p>
Junio C Hamanoa28a9202012-06-21 07:08:231326<a href="git-bisect.html">git-bisect(1)</a>: When there is a regression in your
Junio C Hamanodfccbb02008-05-26 01:16:141327 project, one way to track down the bug is by searching through
Junio C Hamano97bcb482010-11-25 03:16:071328 the history to find the exact commit that&#8217;s to blame. Git bisect
Junio C Hamanodfccbb02008-05-26 01:16:141329 can help you perform a binary search for that commit. It is
1330 smart enough to perform a close-to-optimal search even in the
1331 case of complex non-linear history with lots of merged branches.
1332</p>
1333</li>
1334<li>
1335<p>
Junio C Hamanoa28a9202012-06-21 07:08:231336<a href="gitworkflows.html">gitworkflows(7)</a>: Gives an overview of recommended
Junio C Hamano804b5212009-06-07 16:05:031337 workflows.
1338</p>
1339</li>
1340<li>
1341<p>
Junio C Hamano446e30b2014-10-16 21:30:321342<a href="giteveryday.html">giteveryday(7)</a>: Everyday Git with 20 Commands Or So.
Junio C Hamanodfccbb02008-05-26 01:16:141343</p>
1344</li>
1345<li>
1346<p>
Junio C Hamanoa28a9202012-06-21 07:08:231347<a href="gitcvs-migration.html">gitcvs-migration(7)</a>: Git for CVS users.
Junio C Hamanodfccbb02008-05-26 01:16:141348</p>
1349</li>
Junio C Hamanoba4b9282008-07-06 05:20:311350</ul></div>
Junio C Hamanodfccbb02008-05-26 01:16:141351</div>
Junio C Hamano9d971152012-12-19 00:43:111352</div>
1353<div class="sect1">
Junio C Hamanoba4b9282008-07-06 05:20:311354<h2 id="_see_also">SEE ALSO</h2>
Junio C Hamanodfccbb02008-05-26 01:16:141355<div class="sectionbody">
Junio C Hamanoa28a9202012-06-21 07:08:231356<div class="paragraph"><p><a href="gittutorial-2.html">gittutorial-2(7)</a>,
1357<a href="gitcvs-migration.html">gitcvs-migration(7)</a>,
1358<a href="gitcore-tutorial.html">gitcore-tutorial(7)</a>,
1359<a href="gitglossary.html">gitglossary(7)</a>,
1360<a href="git-help.html">git-help(1)</a>,
1361<a href="gitworkflows.html">gitworkflows(7)</a>,
Junio C Hamano446e30b2014-10-16 21:30:321362<a href="giteveryday.html">giteveryday(7)</a>,
Junio C Hamano97bcb482010-11-25 03:16:071363<a href="user-manual.html">The Git User&#8217;s Manual</a></p></div>
Junio C Hamanodfccbb02008-05-26 01:16:141364</div>
Junio C Hamano9d971152012-12-19 00:43:111365</div>
1366<div class="sect1">
Junio C Hamanoba4b9282008-07-06 05:20:311367<h2 id="_git">GIT</h2>
Junio C Hamanodfccbb02008-05-26 01:16:141368<div class="sectionbody">
Junio C Hamanoe89102f2017-02-15 23:18:151369<div class="paragraph"><p>Part of the <a href="git.html">git(1)</a> suite</p></div>
Junio C Hamanodfccbb02008-05-26 01:16:141370</div>
Junio C Hamano7bd050f2011-09-22 06:32:221371</div>
Junio C Hamano9d971152012-12-19 00:43:111372</div>
Junio C Hamano7bd050f2011-09-22 06:32:221373<div id="footnotes"><hr /></div>
Junio C Hamanodfccbb02008-05-26 01:16:141374<div id="footer">
1375<div id="footer-text">
Junio C Hamano88bf5712017-09-10 08:39:231376Last updated 2017-09-10 17:38:46 JST
Junio C Hamanodfccbb02008-05-26 01:16:141377</div>
1378</div>
1379</body>
1380</html>