blob: 512e4160f69090c506610847ad30378444977df7 [file] [log] [blame]
Junio C Hamano1a4e8412005-12-27 08:17:231<!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 Hamanoc14e6ad2014-10-31 20:25:536<meta name="generator" content="AsciiDoc 8.6.9" />
Junio C Hamano97bcb482010-11-25 03:16:077<title>git-checkout(1)</title>
Junio C Hamano1a4e8412005-12-27 08:17:238<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 Hamano1a4e8412005-12-27 08:17:2324}
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 Hamano1a4e8412005-12-27 08:17:2337
38em {
39 font-style: italic;
Junio C Hamano97bcb482010-11-25 03:16:0740 color: navy;
Junio C Hamano1a4e8412005-12-27 08:17:2341}
42
43strong {
44 font-weight: bold;
Junio C Hamano97bcb482010-11-25 03:16:0745 color: #083194;
Junio C Hamano1a4e8412005-12-27 08:17:2346}
47
Junio C Hamano1a4e8412005-12-27 08:17:2348h1, h2, h3, h4, h5, h6 {
49 color: #527bbd;
Junio C Hamano1a4e8412005-12-27 08:17:2350 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 Hamano1a4e8412005-12-27 08:17:2356 border-bottom: 2px solid silver;
57}
58h2 {
Junio C Hamano1a4e8412005-12-27 08:17:2359 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 Hamano1a4e8412005-12-27 08:17:2370
71div.sectionbody {
Junio C Hamano1a4e8412005-12-27 08:17:2372 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 Hamanoc14e6ad2014-10-31 20:25:5390.monospaced, code, pre {
91 font-family: "Courier New", Courier, monospace;
92 font-size: inherit;
93 color: navy;
Junio C Hamano1a4e8412005-12-27 08:17:2394 padding: 0;
95 margin: 0;
96}
Junio C Hamanoc14e6ad2014-10-31 20:25:5397pre {
98 white-space: pre-wrap;
99}
Junio C Hamano1a4e8412005-12-27 08:17:23100
Junio C Hamano9d971152012-12-19 00:43:11101#author {
Junio C Hamano1a4e8412005-12-27 08:17:23102 color: #527bbd;
Junio C Hamano1a4e8412005-12-27 08:17:23103 font-weight: bold;
Junio C Hamanoba4b9282008-07-06 05:20:31104 font-size: 1.1em;
Junio C Hamano1a4e8412005-12-27 08:17:23105}
Junio C Hamano9d971152012-12-19 00:43:11106#email {
Junio C Hamano1a4e8412005-12-27 08:17:23107}
Junio C Hamano9d971152012-12-19 00:43:11108#revnumber, #revdate, #revremark {
Junio C Hamano1a4e8412005-12-27 08:17:23109}
110
Junio C Hamano9d971152012-12-19 00:43:11111#footer {
Junio C Hamano1a4e8412005-12-27 08:17:23112 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 Hamano1a4e8412005-12-27 08:17:23118 float: left;
119 padding-bottom: 0.5em;
120}
Junio C Hamano9d971152012-12-19 00:43:11121#footer-badges {
Junio C Hamano1a4e8412005-12-27 08:17:23122 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 Hamano1a4e8412005-12-27 08:17:23131div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock,
132div.admonitionblock {
Junio C Hamano7bd050f2011-09-22 06:32:22133 margin-top: 1.0em;
Junio C Hamano1a4e8412005-12-27 08:17:23134 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 Hamano1a4e8412005-12-27 08:17:23141}
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 Hamano1a4e8412005-12-27 08:17:23150 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 Hamano1a4e8412005-12-27 08:17:23173 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 Hamano1a4e8412005-12-27 08:17:23180 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 Hamano1a4e8412005-12-27 08:17:23189}
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 Hamano1a4e8412005-12-27 08:17:23193 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 Hamano1a4e8412005-12-27 08:17:23208
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 Hamano1a4e8412005-12-27 08:17:23220}
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 Hamano1a4e8412005-12-27 08:17:23225}
226
Junio C Hamano1a4e8412005-12-27 08:17:23227div.imageblock div.content { padding-left: 0; }
Junio C Hamanoc14e6ad2014-10-31 20:25:53228span.image img { border-style: none; vertical-align: text-bottom; }
Junio C Hamano97bcb482010-11-25 03:16:07229a.image:visited { color: white; }
Junio C Hamano1a4e8412005-12-27 08:17:23230
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 Hamano1a4e8412005-12-27 08:17:23240}
241dd > *:first-child {
Junio C Hamano97bcb482010-11-25 03:16:07242 margin-top: 0.1em;
Junio C Hamano1a4e8412005-12-27 08:17:23243}
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 Hamano1a4e8412005-12-27 08:17:23252 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 Hamano1a4e8412005-12-27 08:17:23270
Junio C Hamano1a4e8412005-12-27 08:17:23271tfoot {
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 Hamano1a4e8412005-12-27 08:17:23279 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 Hamano1a4e8412005-12-27 08:17:23289 vertical-align: top;
Junio C Hamano97bcb482010-11-25 03:16:07290 font-style: normal;
Junio C Hamano1a4e8412005-12-27 08:17:23291 padding-right: 0.8em;
Junio C Hamano97bcb482010-11-25 03:16:07292 color: navy;
Junio C Hamano1a4e8412005-12-27 08:17:23293}
Junio C Hamano97bcb482010-11-25 03:16:07294td.hdlist2 {
Junio C Hamano1a4e8412005-12-27 08:17:23295 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 Hamano1a4e8412005-12-27 08:17:23305
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 Hamano1a4e8412005-12-27 08:17:23340}
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 Hamanoc14e6ad2014-10-31 20:25:53358div.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 Hamanoc14e6ad2014-10-31 20:25:53416div.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 Hamanoc14e6ad2014-10-31 20:25:53536
537
Junio C Hamano1a4e8412005-12-27 08:17:23538</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 Hamanoc14e6ad2014-10-31 20:25:53582 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 Hamanoc14e6ad2014-10-31 20:25:53611 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 Hamanoc14e6ad2014-10-31 20:25:53657 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 Hamano1a4e8412005-12-27 08:17:23733</head>
Junio C Hamano9d971152012-12-19 00:43:11734<body class="manpage">
Junio C Hamano1a4e8412005-12-27 08:17:23735<div id="header">
736<h1>
737git-checkout(1) Manual Page
738</h1>
739<h2>NAME</h2>
740<div class="sectionbody">
741<p>git-checkout -
Junio C Hamano823eebb2015-07-10 22:29:34742 Switch branches or restore working tree files
Junio C Hamano1a4e8412005-12-27 08:17:23743</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 Hamano1a4e8412005-12-27 08:17:23749<div class="sectionbody">
Junio C Hamano2b135272006-03-18 07:45:42750<div class="verseblock">
Junio C Hamano9d971152012-12-19 00:43:11751<pre class="content"><em>git checkout</em> [-q] [-f] [-m] [&lt;branch&gt;]
Junio C Hamanof2d4a132013-10-18 04:34:41752<em>git checkout</em> [-q] [-f] [-m] --detach [&lt;branch&gt;]
753<em>git checkout</em> [-q] [-f] [-m] [--detach] &lt;commit&gt;
Junio C Hamano619596a2010-08-18 22:15:35754<em>git checkout</em> [-q] [-f] [-m] [[-b|-B|--orphan] &lt;new_branch&gt;] [&lt;start_point&gt;]
Junio C Hamanoc28068f2009-09-08 00:55:23755<em>git checkout</em> [-f|--ours|--theirs|-m|--conflict=&lt;style&gt;] [&lt;tree-ish&gt;] [--] &lt;paths&gt;&#8230;
Junio C Hamano9d971152012-12-19 00:43:11756<em>git checkout</em> [-p|--patch] [&lt;tree-ish&gt;] [--] [&lt;paths&gt;&#8230;]</pre>
757<div class="attribution">
Junio C Hamano97bcb482010-11-25 03:16:07758</div></div>
Junio C Hamano1a4e8412005-12-27 08:17:23759</div>
Junio C Hamano9d971152012-12-19 00:43:11760</div>
761<div class="sect1">
Junio C Hamanoba4b9282008-07-06 05:20:31762<h2 id="_description">DESCRIPTION</h2>
Junio C Hamano1a4e8412005-12-27 08:17:23763<div class="sectionbody">
Junio C Hamano97bcb482010-11-25 03:16:07764<div class="paragraph"><p>Updates files in the working tree to match the version in the index
Junio C Hamanobb88cf42010-06-21 15:23:55765or the specified tree. If no paths are given, <em>git checkout</em> will
Junio C Hamanoc14e6ad2014-10-31 20:25:53766also update <code>HEAD</code> to set the specified branch as the current
Junio C Hamano3bd66e92009-04-18 06:17:56767branch.</p></div>
Junio C Hamano97bcb482010-11-25 03:16:07768<div class="dlist"><dl>
769<dt class="hdlist1">
Junio C Hamanodb81b992012-12-21 23:49:12770<em>git checkout</em> &lt;branch&gt;
Junio C Hamano63c2bc92011-02-28 06:41:28771</dt>
Junio C Hamanobb88cf42010-06-21 15:23:55772<dd>
773<p>
Junio C Hamanodb81b992012-12-21 23:49:12774 To prepare for working on &lt;branch&gt;, switch to it by updating
775 the index and the files in the working tree, and by pointing
776 HEAD at the branch. Local modifications to the files in the
777 working tree are kept, so that they can be committed to the
778 &lt;branch&gt;.
Junio C Hamanobb88cf42010-06-21 15:23:55779</p>
Junio C Hamanodb81b992012-12-21 23:49:12780<div class="paragraph"><p>If &lt;branch&gt; is not found but there does exist a tracking branch in
781exactly one remote (call it &lt;remote&gt;) with a matching name, treat as
782equivalent to</p></div>
783<div class="listingblock">
784<div class="content">
Junio C Hamanoc14e6ad2014-10-31 20:25:53785<pre><code>$ git checkout -b &lt;branch&gt; --track &lt;remote&gt;/&lt;branch&gt;</code></pre>
Junio C Hamanodb81b992012-12-21 23:49:12786</div></div>
787<div class="paragraph"><p>You could omit &lt;branch&gt;, in which case the command degenerates to
788"check out the current branch", which is a glorified no-op with a
789rather expensive side-effects to show only the tracking information,
790if exists, for the current branch.</p></div>
791</dd>
792<dt class="hdlist1">
793<em>git checkout</em> -b|-B &lt;new_branch&gt; [&lt;start point&gt;]
794</dt>
795<dd>
796<p>
Junio C Hamanoc14e6ad2014-10-31 20:25:53797 Specifying <code>-b</code> causes a new branch to be created as if
Junio C Hamanodb81b992012-12-21 23:49:12798 <a href="git-branch.html">git-branch(1)</a> were called and then checked out. In
Junio C Hamanoc14e6ad2014-10-31 20:25:53799 this case you can use the <code>--track</code> or <code>--no-track</code> options,
Junio C Hamanodb81b992012-12-21 23:49:12800 which will be passed to <em>git branch</em>. As a convenience,
Junio C Hamanoc14e6ad2014-10-31 20:25:53801 <code>--track</code> without <code>-b</code> implies branch creation; see the
802 description of <code>--track</code> below.
Junio C Hamanodb81b992012-12-21 23:49:12803</p>
Junio C Hamanoc14e6ad2014-10-31 20:25:53804<div class="paragraph"><p>If <code>-B</code> is given, &lt;new_branch&gt; is created if it doesn&#8217;t exist; otherwise, it
Junio C Hamano619596a2010-08-18 22:15:35805is reset. This is the transactional equivalent of</p></div>
806<div class="listingblock">
807<div class="content">
Junio C Hamanoc14e6ad2014-10-31 20:25:53808<pre><code>$ git branch -f &lt;branch&gt; [&lt;start point&gt;]
809$ git checkout &lt;branch&gt;</code></pre>
Junio C Hamano619596a2010-08-18 22:15:35810</div></div>
Junio C Hamano97bcb482010-11-25 03:16:07811<div class="paragraph"><p>that is to say, the branch is not reset/created unless "git checkout" is
Junio C Hamano619596a2010-08-18 22:15:35812successful.</p></div>
Junio C Hamanobb88cf42010-06-21 15:23:55813</dd>
Junio C Hamano97bcb482010-11-25 03:16:07814<dt class="hdlist1">
Junio C Hamanodb81b992012-12-21 23:49:12815<em>git checkout</em> --detach [&lt;branch&gt;]
816</dt>
817<dt class="hdlist1">
Junio C Hamanof2d4a132013-10-18 04:34:41818<em>git checkout</em> [--detach] &lt;commit&gt;
Junio C Hamanodb81b992012-12-21 23:49:12819</dt>
820<dd>
821<p>
822 Prepare to work on top of &lt;commit&gt;, by detaching HEAD at it
823 (see "DETACHED HEAD" section), and updating the index and the
824 files in the working tree. Local modifications to the files
825 in the working tree are kept, so that the resulting working
826 tree will be the state recorded in the commit plus the local
827 modifications.
828</p>
Junio C Hamanoc14e6ad2014-10-31 20:25:53829<div class="paragraph"><p>When the &lt;commit&gt; argument is a branch name, the <code>--detach</code> option can
830be used to detach HEAD at the tip of the branch (<code>git checkout
831&lt;branch&gt;</code> would check out that branch without detaching HEAD).</p></div>
Junio C Hamanof2d4a132013-10-18 04:34:41832<div class="paragraph"><p>Omitting &lt;branch&gt; detaches HEAD at the tip of the current branch.</p></div>
Junio C Hamanodb81b992012-12-21 23:49:12833</dd>
834<dt class="hdlist1">
Junio C Hamano9eb58352011-05-11 20:09:24835<em>git checkout</em> [-p|--patch] [&lt;tree-ish&gt;] [--] &lt;pathspec&gt;&#8230;
Junio C Hamanobb88cf42010-06-21 15:23:55836</dt>
837<dd>
838<p>
Junio C Hamanoc14e6ad2014-10-31 20:25:53839 When &lt;paths&gt; or <code>--patch</code> are given, <em>git checkout</em> does <strong>not</strong>
Junio C Hamano442206c2010-09-28 05:51:23840 switch branches. It updates the named paths in the working tree
841 from the index file or from a named &lt;tree-ish&gt; (most often a
Junio C Hamanoc14e6ad2014-10-31 20:25:53842 commit). In this case, the <code>-b</code> and <code>--track</code> options are
Junio C Hamano442206c2010-09-28 05:51:23843 meaningless and giving either of them results in an error. The
844 &lt;tree-ish&gt; argument can be used to specify a specific tree-ish
845 (i.e. commit, tag or tree) to update the index for the given
846 paths before updating the working tree.
Junio C Hamanobb88cf42010-06-21 15:23:55847</p>
Junio C Hamano823eebb2015-07-10 22:29:34848<div class="paragraph"><p><em>git checkout</em> with &lt;paths&gt; or <code>--patch</code> is used to restore modified or
849deleted paths to their original contents from the index or replace paths
850with the contents from a named &lt;tree-ish&gt; (most often a commit-ish).</p></div>
Junio C Hamano97bcb482010-11-25 03:16:07851<div class="paragraph"><p>The index may contain unmerged entries because of a previous failed merge.
Junio C Hamanobb88cf42010-06-21 15:23:55852By default, if you try to check out such an entry from the index, the
Junio C Hamanoa476efa2008-10-10 15:31:42853checkout operation will fail and nothing will be checked out.
Junio C Hamanoc14e6ad2014-10-31 20:25:53854Using <code>-f</code> will ignore these unmerged entries. The contents from a
Junio C Hamanoa476efa2008-10-10 15:31:42855specific side of the merge can be checked out of the index by
Junio C Hamanoc14e6ad2014-10-31 20:25:53856using <code>--ours</code> or <code>--theirs</code>. With <code>-m</code>, changes made to the working tree
Junio C Hamanobb88cf42010-06-21 15:23:55857file can be discarded to re-create the original conflicted merge result.</p></div>
858</dd>
859</dl></div>
Junio C Hamano1a4e8412005-12-27 08:17:23860</div>
Junio C Hamano9d971152012-12-19 00:43:11861</div>
862<div class="sect1">
Junio C Hamanoba4b9282008-07-06 05:20:31863<h2 id="_options">OPTIONS</h2>
Junio C Hamano1a4e8412005-12-27 08:17:23864<div class="sectionbody">
Junio C Hamano97bcb482010-11-25 03:16:07865<div class="dlist"><dl>
866<dt class="hdlist1">
Junio C Hamano39381a72007-02-02 07:35:15867-q
868</dt>
Junio C Hamano97bcb482010-11-25 03:16:07869<dt class="hdlist1">
Junio C Hamano68cfa3a2009-08-30 00:22:55870--quiet
871</dt>
Junio C Hamano39381a72007-02-02 07:35:15872<dd>
873<p>
Junio C Hamanocae86272007-08-21 02:20:49874 Quiet, suppress feedback messages.
Junio C Hamano39381a72007-02-02 07:35:15875</p>
876</dd>
Junio C Hamano97bcb482010-11-25 03:16:07877<dt class="hdlist1">
Junio C Hamano89c34e32015-11-06 23:26:20878--[no-]progress
879</dt>
880<dd>
881<p>
882 Progress status is reported on the standard error stream
883 by default when it is attached to a terminal, unless <code>--quiet</code>
884 is specified. This flag enables progress reporting even if not
885 attached to a terminal, regardless of <code>--quiet</code>.
886</p>
887</dd>
888<dt class="hdlist1">
Junio C Hamano1a4e8412005-12-27 08:17:23889-f
890</dt>
Junio C Hamano97bcb482010-11-25 03:16:07891<dt class="hdlist1">
Junio C Hamano68cfa3a2009-08-30 00:22:55892--force
893</dt>
Junio C Hamano1a4e8412005-12-27 08:17:23894<dd>
895<p>
Junio C Hamanoa476efa2008-10-10 15:31:42896 When switching branches, proceed even if the index or the
897 working tree differs from HEAD. This is used to throw away
898 local changes.
899</p>
Junio C Hamano97bcb482010-11-25 03:16:07900<div class="paragraph"><p>When checking out paths from the index, do not fail upon unmerged
Junio C Hamanoa476efa2008-10-10 15:31:42901entries; instead, unmerged entries are ignored.</p></div>
902</dd>
Junio C Hamano97bcb482010-11-25 03:16:07903<dt class="hdlist1">
Junio C Hamanoa476efa2008-10-10 15:31:42904--ours
905</dt>
Junio C Hamano97bcb482010-11-25 03:16:07906<dt class="hdlist1">
Junio C Hamanoa476efa2008-10-10 15:31:42907--theirs
908</dt>
909<dd>
910<p>
911 When checking out paths from the index, check out stage #2
912 (<em>ours</em>) or #3 (<em>theirs</em>) for unmerged paths.
Junio C Hamano1a4e8412005-12-27 08:17:23913</p>
Junio C Hamanod7ed4042015-08-03 19:43:00914<div class="paragraph"><p>Note that during <code>git rebase</code> and <code>git pull --rebase</code>, <em>ours</em> and
915<em>theirs</em> may appear swapped; <code>--ours</code> gives the version from the
916branch the changes are rebased onto, while <code>--theirs</code> gives the
917version from the branch that holds your work that is being rebased.</p></div>
918<div class="paragraph"><p>This is because <code>rebase</code> is used in a workflow that treats the
919history at the remote as the shared canonical one, and treats the
920work done on the branch you are rebasing as the third-party work to
921be integrated, and you are temporarily assuming the role of the
922keeper of the canonical history during the rebase. As the keeper of
923the canonical history, you need to view the history from the remote
924as <code>ours</code> (i.e. "our shared canonical history"), while what you did
925on your side branch as <code>theirs</code> (i.e. "one contributor&#8217;s work on top
926of it").</p></div>
Junio C Hamano1a4e8412005-12-27 08:17:23927</dd>
Junio C Hamano97bcb482010-11-25 03:16:07928<dt class="hdlist1">
Junio C Hamanoeccdd4a2012-09-10 23:28:17929-b &lt;new_branch&gt;
Junio C Hamano1a4e8412005-12-27 08:17:23930</dt>
931<dd>
932<p>
Junio C Hamanob2f5edd2006-05-21 10:50:09933 Create a new branch named &lt;new_branch&gt; and start it at
Junio C Hamanoa28a9202012-06-21 07:08:23934 &lt;start_point&gt;; see <a href="git-branch.html">git-branch(1)</a> for details.
Junio C Hamano1a4e8412005-12-27 08:17:23935</p>
936</dd>
Junio C Hamano97bcb482010-11-25 03:16:07937<dt class="hdlist1">
Junio C Hamanoeccdd4a2012-09-10 23:28:17938-B &lt;new_branch&gt;
Junio C Hamano619596a2010-08-18 22:15:35939</dt>
940<dd>
941<p>
942 Creates the branch &lt;new_branch&gt; and start it at &lt;start_point&gt;;
943 if it already exists, then reset it to &lt;start_point&gt;. This is
944 equivalent to running "git branch" with "-f"; see
Junio C Hamanoa28a9202012-06-21 07:08:23945 <a href="git-branch.html">git-branch(1)</a> for details.
Junio C Hamano619596a2010-08-18 22:15:35946</p>
947</dd>
Junio C Hamano97bcb482010-11-25 03:16:07948<dt class="hdlist1">
Junio C Hamanoeb415992008-06-08 22:49:47949-t
950</dt>
Junio C Hamano97bcb482010-11-25 03:16:07951<dt class="hdlist1">
Junio C Hamanoeb415992008-06-08 22:49:47952--track
Junio C Hamano103ad7f2007-03-14 11:19:26953</dt>
954<dd>
955<p>
Junio C Hamano3bd66e92009-04-18 06:17:56956 When creating a new branch, set up "upstream" configuration. See
Junio C Hamanoa28a9202012-06-21 07:08:23957 "--track" in <a href="git-branch.html">git-branch(1)</a> for details.
Junio C Hamano103ad7f2007-03-14 11:19:26958</p>
Junio C Hamano92d80372016-07-13 22:00:05959<div class="paragraph"><p>If no <code>-b</code> option is given, the name of the new branch will be
Junio C Hamanoc7102962013-05-29 23:57:17960derived from the remote-tracking branch, by looking at the local part of
961the refspec configured for the corresponding remote, and then stripping
962the initial part up to the "*".
Junio C Hamano043628e2008-08-24 03:34:11963This would tell us to use "hack" as the local branch when branching
964off of "origin/hack" (or "remotes/origin/hack", or even
965"refs/remotes/origin/hack"). If the given name has no slash, or the above
966guessing results in an empty name, the guessing is aborted. You can
Junio C Hamano92d80372016-07-13 22:00:05967explicitly give a name with <code>-b</code> in such a case.</p></div>
Junio C Hamano103ad7f2007-03-14 11:19:26968</dd>
Junio C Hamano97bcb482010-11-25 03:16:07969<dt class="hdlist1">
Junio C Hamano103ad7f2007-03-14 11:19:26970--no-track
971</dt>
972<dd>
973<p>
Junio C Hamano3bd66e92009-04-18 06:17:56974 Do not set up "upstream" configuration, even if the
Junio C Hamano322c6242015-03-23 21:32:46975 branch.autoSetupMerge configuration variable is true.
Junio C Hamano103ad7f2007-03-14 11:19:26976</p>
977</dd>
Junio C Hamano97bcb482010-11-25 03:16:07978<dt class="hdlist1">
Junio C Hamano341071d2006-06-04 07:24:48979-l
980</dt>
981<dd>
982<p>
Junio C Hamanoa28a9202012-06-21 07:08:23983 Create the new branch&#8217;s reflog; see <a href="git-branch.html">git-branch(1)</a> for
Junio C Hamano3bd66e92009-04-18 06:17:56984 details.
Junio C Hamano341071d2006-06-04 07:24:48985</p>
986</dd>
Junio C Hamano97bcb482010-11-25 03:16:07987<dt class="hdlist1">
Junio C Hamano63c2bc92011-02-28 06:41:28988--detach
989</dt>
990<dd>
991<p>
992 Rather than checking out a branch to work on it, check out a
993 commit for inspection and discardable experiments.
994 This is the default behavior of "git checkout &lt;commit&gt;" when
995 &lt;commit&gt; is not a branch name. See the "DETACHED HEAD" section
996 below for details.
997</p>
998</dd>
999<dt class="hdlist1">
Junio C Hamanoeccdd4a2012-09-10 23:28:171000--orphan &lt;new_branch&gt;
Junio C Hamanocc7636a2010-05-21 14:57:531001</dt>
1002<dd>
1003<p>
Junio C Hamanobb88cf42010-06-21 15:23:551004 Create a new <em>orphan</em> branch, named &lt;new_branch&gt;, started from
1005 &lt;start_point&gt; and switch to it. The first commit made on this
1006 new branch will have no parents and it will be the root of a new
1007 history totally disconnected from all the other branches and
1008 commits.
Junio C Hamanocc7636a2010-05-21 14:57:531009</p>
Junio C Hamano97bcb482010-11-25 03:16:071010<div class="paragraph"><p>The index and the working tree are adjusted as if you had previously run
Junio C Hamanobb88cf42010-06-21 15:23:551011"git checkout &lt;start_point&gt;". This allows you to start a new history
1012that records a set of paths similar to &lt;start_point&gt; by easily running
1013"git commit -a" to make the root commit.</p></div>
Junio C Hamano97bcb482010-11-25 03:16:071014<div class="paragraph"><p>This can be useful when you want to publish the tree from a commit
Junio C Hamanobb88cf42010-06-21 15:23:551015without exposing its full history. You might want to do this to publish
1016an open source branch of a project whose current tree is "clean", but
1017whose full history contains proprietary or otherwise encumbered bits of
1018code.</p></div>
Junio C Hamano97bcb482010-11-25 03:16:071019<div class="paragraph"><p>If you want to start a disconnected history that records a set of paths
Junio C Hamanobb88cf42010-06-21 15:23:551020that is totally different from the one of &lt;start_point&gt;, then you should
1021clear the index and the working tree right after creating the orphan
1022branch by running "git rm -rf ." from the top level of the working tree.
1023Afterwards you will be ready to prepare your new files, repopulating the
1024working tree, by copying them from elsewhere, extracting a tarball, etc.</p></div>
Junio C Hamanocc7636a2010-05-21 14:57:531025</dd>
Junio C Hamano97bcb482010-11-25 03:16:071026<dt class="hdlist1">
Junio C Hamanoc79bc672013-04-22 19:12:471027--ignore-skip-worktree-bits
1028</dt>
1029<dd>
1030<p>
Junio C Hamanoc14e6ad2014-10-31 20:25:531031 In sparse checkout mode, <code>git checkout -- &lt;paths&gt;</code> would
Junio C Hamanoc79bc672013-04-22 19:12:471032 update only entries matched by &lt;paths&gt; and sparse patterns
1033 in $GIT_DIR/info/sparse-checkout. This option ignores
1034 the sparse patterns and adds back any files in &lt;paths&gt;.
1035</p>
1036</dd>
1037<dt class="hdlist1">
Junio C Hamano74e8a2d2006-01-14 03:58:411038-m
1039</dt>
Junio C Hamano97bcb482010-11-25 03:16:071040<dt class="hdlist1">
Junio C Hamanoa476efa2008-10-10 15:31:421041--merge
1042</dt>
Junio C Hamano74e8a2d2006-01-14 03:58:411043<dd>
1044<p>
Junio C Hamanoa476efa2008-10-10 15:31:421045 When switching branches,
1046 if you have local modifications to one or more files that
Junio C Hamano2b135272006-03-18 07:45:421047 are different between the current branch and the branch to
1048 which you are switching, the command refuses to switch
1049 branches in order to preserve your modifications in context.
1050 However, with this option, a three-way merge between the current
Junio C Hamano74e8a2d2006-01-14 03:58:411051 branch, your working tree contents, and the new branch
1052 is done, and you will be on the new branch.
1053</p>
Junio C Hamano97bcb482010-11-25 03:16:071054<div class="paragraph"><p>When a merge conflict happens, the index entries for conflicting
Junio C Hamano74e8a2d2006-01-14 03:58:411055paths are left unmerged, and you need to resolve the conflicts
Junio C Hamanoc14e6ad2014-10-31 20:25:531056and mark the resolved paths with <code>git add</code> (or <code>git rm</code> if the merge
Junio C Hamanoba4b9282008-07-06 05:20:311057should result in deletion of the path).</p></div>
Junio C Hamano97bcb482010-11-25 03:16:071058<div class="paragraph"><p>When checking out paths from the index, this option lets you recreate
Junio C Hamanoa476efa2008-10-10 15:31:421059the conflicted merge in the specified paths.</p></div>
1060</dd>
Junio C Hamano97bcb482010-11-25 03:16:071061<dt class="hdlist1">
Junio C Hamanoa476efa2008-10-10 15:31:421062--conflict=&lt;style&gt;
1063</dt>
1064<dd>
1065<p>
1066 The same as --merge option above, but changes the way the
1067 conflicting hunks are presented, overriding the
Junio C Hamano322c6242015-03-23 21:32:461068 merge.conflictStyle configuration variable. Possible values are
Junio C Hamanoa476efa2008-10-10 15:31:421069 "merge" (default) and "diff3" (in addition to what is shown by
1070 "merge" style, shows the original contents).
1071</p>
Junio C Hamano74e8a2d2006-01-14 03:58:411072</dd>
Junio C Hamano97bcb482010-11-25 03:16:071073<dt class="hdlist1">
Junio C Hamanoc28068f2009-09-08 00:55:231074-p
1075</dt>
Junio C Hamano97bcb482010-11-25 03:16:071076<dt class="hdlist1">
Junio C Hamanoc28068f2009-09-08 00:55:231077--patch
1078</dt>
1079<dd>
1080<p>
1081 Interactively select hunks in the difference between the
1082 &lt;tree-ish&gt; (or the index, if unspecified) and the working
1083 tree. The chosen hunks are then applied in reverse to the
1084 working tree (and if a &lt;tree-ish&gt; was specified, the index).
1085</p>
Junio C Hamanoc14e6ad2014-10-31 20:25:531086<div class="paragraph"><p>This means that you can use <code>git checkout -p</code> to selectively discard
Junio C Hamano9d971152012-12-19 00:43:111087edits from your current working tree. See the &#8220;Interactive Mode&#8221;
Junio C Hamanoc14e6ad2014-10-31 20:25:531088section of <a href="git-add.html">git-add(1)</a> to learn how to operate the <code>--patch</code> mode.</p></div>
Junio C Hamanoc28068f2009-09-08 00:55:231089</dd>
Junio C Hamano97bcb482010-11-25 03:16:071090<dt class="hdlist1">
Junio C Hamano4cc4a842015-05-11 22:41:021091--ignore-other-worktrees
1092</dt>
1093<dd>
1094<p>
1095 <code>git checkout</code> refuses when the wanted ref is already checked
1096 out by another worktree. This option makes it check the ref
1097 out anyway. In other words, the ref can be held by more than one
1098 worktree.
1099</p>
1100</dd>
1101<dt class="hdlist1">
Junio C Hamano3bd66e92009-04-18 06:17:561102&lt;branch&gt;
1103</dt>
1104<dd>
1105<p>
1106 Branch to checkout; if it refers to a branch (i.e., a name that,
1107 when prepended with "refs/heads/", is a valid ref), then that
1108 branch is checked out. Otherwise, if it refers to a valid
1109 commit, your HEAD becomes "detached" and you are no longer on
1110 any branch (see below for details).
1111</p>
Junio C Hamanoc14e6ad2014-10-31 20:25:531112<div class="paragraph"><p>As a special case, the <code>"@{-N}"</code> syntax for the N-th last branch/commit
Junio C Hamanoc5bd79e2014-01-27 21:31:261113checks out branches (instead of detaching). You may also specify
Junio C Hamanoc14e6ad2014-10-31 20:25:531114<code>-</code> which is synonymous with <code>"@{-1}"</code>.</p></div>
1115<div class="paragraph"><p>As a further special case, you may use <code>"A...B"</code> as a shortcut for the
1116merge base of <code>A</code> and <code>B</code> if there is exactly one merge base. You can
1117leave out at most one of <code>A</code> and <code>B</code>, in which case it defaults to <code>HEAD</code>.</p></div>
Junio C Hamano3bd66e92009-04-18 06:17:561118</dd>
Junio C Hamano97bcb482010-11-25 03:16:071119<dt class="hdlist1">
Junio C Hamano1a4e8412005-12-27 08:17:231120&lt;new_branch&gt;
1121</dt>
1122<dd>
1123<p>
1124 Name for the new branch.
1125</p>
1126</dd>
Junio C Hamano97bcb482010-11-25 03:16:071127<dt class="hdlist1">
Junio C Hamano3bd66e92009-04-18 06:17:561128&lt;start_point&gt;
1129</dt>
1130<dd>
1131<p>
1132 The name of a commit at which to start the new branch; see
Junio C Hamanoa28a9202012-06-21 07:08:231133 <a href="git-branch.html">git-branch(1)</a> for details. Defaults to HEAD.
Junio C Hamano3bd66e92009-04-18 06:17:561134</p>
1135</dd>
Junio C Hamano97bcb482010-11-25 03:16:071136<dt class="hdlist1">
Junio C Hamanob4a9ede2009-04-08 07:36:321137&lt;tree-ish&gt;
1138</dt>
1139<dd>
1140<p>
1141 Tree to checkout from (when paths are given). If not specified,
1142 the index will be used.
1143</p>
1144</dd>
Junio C Hamanoba4b9282008-07-06 05:20:311145</dl></div>
Junio C Hamano1a4e8412005-12-27 08:17:231146</div>
Junio C Hamano9d971152012-12-19 00:43:111147</div>
1148<div class="sect1">
Junio C Hamano63c2bc92011-02-28 06:41:281149<h2 id="_detached_head">DETACHED HEAD</h2>
Junio C Hamano4f9a6052007-01-17 20:25:161150<div class="sectionbody">
Junio C Hamano63c2bc92011-02-28 06:41:281151<div class="paragraph"><p>HEAD normally refers to a named branch (e.g. <em>master</em>). Meanwhile, each
1152branch refers to a specific commit. Let&#8217;s look at a repo with three
1153commits, one of them tagged, and with branch <em>master</em> checked out:</p></div>
Junio C Hamano4f9a6052007-01-17 20:25:161154<div class="listingblock">
1155<div class="content">
Junio C Hamanoc14e6ad2014-10-31 20:25:531156<pre><code> HEAD (refers to branch 'master')
Junio C Hamano63c2bc92011-02-28 06:41:281157 |
1158 v
1159a---b---c branch 'master' (refers to commit 'c')
1160 ^
1161 |
Junio C Hamanoc14e6ad2014-10-31 20:25:531162 tag 'v2.0' (refers to commit 'b')</code></pre>
Junio C Hamano4f9a6052007-01-17 20:25:161163</div></div>
Junio C Hamano63c2bc92011-02-28 06:41:281164<div class="paragraph"><p>When a commit is created in this state, the branch is updated to refer to
1165the new commit. Specifically, <em>git commit</em> creates a new commit <em>d</em>, whose
1166parent is commit <em>c</em>, and then updates branch <em>master</em> to refer to new
1167commit <em>d</em>. HEAD still refers to branch <em>master</em> and so indirectly now refers
1168to commit <em>d</em>:</p></div>
Junio C Hamano9d52e572007-02-13 23:48:201169<div class="listingblock">
1170<div class="content">
Junio C Hamanoc14e6ad2014-10-31 20:25:531171<pre><code>$ edit; git add; git commit
Junio C Hamano63c2bc92011-02-28 06:41:281172
1173 HEAD (refers to branch 'master')
1174 |
1175 v
1176a---b---c---d branch 'master' (refers to commit 'd')
1177 ^
1178 |
Junio C Hamanoc14e6ad2014-10-31 20:25:531179 tag 'v2.0' (refers to commit 'b')</code></pre>
Junio C Hamano63c2bc92011-02-28 06:41:281180</div></div>
1181<div class="paragraph"><p>It is sometimes useful to be able to checkout a commit that is not at
1182the tip of any named branch, or even to create a new commit that is not
1183referenced by a named branch. Let&#8217;s look at what happens when we
1184checkout commit <em>b</em> (here we show two ways this may be done):</p></div>
1185<div class="listingblock">
1186<div class="content">
Junio C Hamanoc14e6ad2014-10-31 20:25:531187<pre><code>$ git checkout v2.0 # or
Junio C Hamano63c2bc92011-02-28 06:41:281188$ git checkout master^^
1189
1190 HEAD (refers to commit 'b')
1191 |
1192 v
1193a---b---c---d branch 'master' (refers to commit 'd')
1194 ^
1195 |
Junio C Hamanoc14e6ad2014-10-31 20:25:531196 tag 'v2.0' (refers to commit 'b')</code></pre>
Junio C Hamano63c2bc92011-02-28 06:41:281197</div></div>
1198<div class="paragraph"><p>Notice that regardless of which checkout command we use, HEAD now refers
1199directly to commit <em>b</em>. This is known as being in detached HEAD state.
1200It means simply that HEAD refers to a specific commit, as opposed to
1201referring to a named branch. Let&#8217;s see what happens when we create a commit:</p></div>
1202<div class="listingblock">
1203<div class="content">
Junio C Hamanoc14e6ad2014-10-31 20:25:531204<pre><code>$ edit; git add; git commit
Junio C Hamano63c2bc92011-02-28 06:41:281205
1206 HEAD (refers to commit 'e')
1207 |
1208 v
1209 e
1210 /
1211a---b---c---d branch 'master' (refers to commit 'd')
1212 ^
1213 |
Junio C Hamanoc14e6ad2014-10-31 20:25:531214 tag 'v2.0' (refers to commit 'b')</code></pre>
Junio C Hamano63c2bc92011-02-28 06:41:281215</div></div>
1216<div class="paragraph"><p>There is now a new commit <em>e</em>, but it is referenced only by HEAD. We can
1217of course add yet another commit in this state:</p></div>
1218<div class="listingblock">
1219<div class="content">
Junio C Hamanoc14e6ad2014-10-31 20:25:531220<pre><code>$ edit; git add; git commit
Junio C Hamano63c2bc92011-02-28 06:41:281221
1222 HEAD (refers to commit 'f')
1223 |
1224 v
1225 e---f
1226 /
1227a---b---c---d branch 'master' (refers to commit 'd')
1228 ^
1229 |
Junio C Hamanoc14e6ad2014-10-31 20:25:531230 tag 'v2.0' (refers to commit 'b')</code></pre>
Junio C Hamano63c2bc92011-02-28 06:41:281231</div></div>
Junio C Hamano076ffcc2013-02-06 05:13:211232<div class="paragraph"><p>In fact, we can perform all the normal Git operations. But, let&#8217;s look
Junio C Hamano63c2bc92011-02-28 06:41:281233at what happens when we then checkout master:</p></div>
1234<div class="listingblock">
1235<div class="content">
Junio C Hamanoc14e6ad2014-10-31 20:25:531236<pre><code>$ git checkout master
Junio C Hamano63c2bc92011-02-28 06:41:281237
1238 HEAD (refers to branch 'master')
1239 e---f |
1240 / v
1241a---b---c---d branch 'master' (refers to commit 'd')
1242 ^
1243 |
Junio C Hamanoc14e6ad2014-10-31 20:25:531244 tag 'v2.0' (refers to commit 'b')</code></pre>
Junio C Hamano63c2bc92011-02-28 06:41:281245</div></div>
1246<div class="paragraph"><p>It is important to realize that at this point nothing refers to commit
1247<em>f</em>. Eventually commit <em>f</em> (and by extension commit <em>e</em>) will be deleted
Junio C Hamano076ffcc2013-02-06 05:13:211248by the routine Git garbage collection process, unless we create a reference
Junio C Hamano63c2bc92011-02-28 06:41:281249before that happens. If we have not yet moved away from commit <em>f</em>,
1250any of these will create a reference to it:</p></div>
1251<div class="listingblock">
1252<div class="content">
Junio C Hamanoc14e6ad2014-10-31 20:25:531253<pre><code>$ git checkout -b foo <b>&lt;1&gt;</b>
Junio C Hamano63c2bc92011-02-28 06:41:281254$ git branch foo <b>&lt;2&gt;</b>
Junio C Hamanoc14e6ad2014-10-31 20:25:531255$ git tag foo <b>&lt;3&gt;</b></code></pre>
Junio C Hamano63c2bc92011-02-28 06:41:281256</div></div>
1257<div class="colist arabic"><ol>
1258<li>
1259<p>
1260creates a new branch <em>foo</em>, which refers to commit <em>f</em>, and then
1261updates HEAD to refer to branch <em>foo</em>. In other words, we&#8217;ll no longer
1262be in detached HEAD state after this command.
1263</p>
1264</li>
1265<li>
1266<p>
1267similarly creates a new branch <em>foo</em>, which refers to commit <em>f</em>,
1268but leaves HEAD detached.
1269</p>
1270</li>
1271<li>
1272<p>
1273creates a new tag <em>foo</em>, which refers to commit <em>f</em>,
1274leaving HEAD detached.
1275</p>
1276</li>
1277</ol></div>
1278<div class="paragraph"><p>If we have moved away from commit <em>f</em>, then we must first recover its object
1279name (typically by using git reflog), and then we can create a reference to
1280it. For example, to see the last two commits to which HEAD referred, we
1281can use either of these commands:</p></div>
1282<div class="listingblock">
1283<div class="content">
Junio C Hamanoc14e6ad2014-10-31 20:25:531284<pre><code>$ git reflog -2 HEAD # or
1285$ git log -g -2 HEAD</code></pre>
Junio C Hamano9d52e572007-02-13 23:48:201286</div></div>
Junio C Hamano4f9a6052007-01-17 20:25:161287</div>
Junio C Hamano9d971152012-12-19 00:43:111288</div>
1289<div class="sect1">
Junio C Hamanoad70bf02016-09-26 23:44:271290<h2 id="_argument_disambiguation">ARGUMENT DISAMBIGUATION</h2>
1291<div class="sectionbody">
1292<div class="paragraph"><p>When there is only one argument given and it is not <code>--</code> (e.g. "git
1293checkout abc"), and when the argument is both a valid <code>&lt;tree-ish&gt;</code>
1294(e.g. a branch "abc" exists) and a valid <code>&lt;pathspec&gt;</code> (e.g. a file
1295or a directory whose name is "abc" exists), Git would usually ask
1296you to disambiguate. Because checking out a branch is so common an
1297operation, however, "git checkout abc" takes "abc" as a <code>&lt;tree-ish&gt;</code>
1298in such a situation. Use <code>git checkout -- &lt;pathspec&gt;</code> if you want
1299to checkout these paths out of the index.</p></div>
1300</div>
1301</div>
1302<div class="sect1">
Junio C Hamanoba4b9282008-07-06 05:20:311303<h2 id="_examples">EXAMPLES</h2>
Junio C Hamano1a4e8412005-12-27 08:17:231304<div class="sectionbody">
Junio C Hamano97bcb482010-11-25 03:16:071305<div class="olist arabic"><ol class="arabic">
Junio C Hamano74e8a2d2006-01-14 03:58:411306<li>
1307<p>
Junio C Hamanoc14e6ad2014-10-31 20:25:531308The following sequence checks out the <code>master</code> branch, reverts
1309the <code>Makefile</code> to two revisions back, deletes hello.c by
Junio C Hamano74e8a2d2006-01-14 03:58:411310mistake, and gets it back from the index.
1311</p>
Junio C Hamano1a4e8412005-12-27 08:17:231312<div class="listingblock">
1313<div class="content">
Junio C Hamanoc14e6ad2014-10-31 20:25:531314<pre><code>$ git checkout master <b>&lt;1&gt;</b>
Junio C Hamano97bcb482010-11-25 03:16:071315$ git checkout master~2 Makefile <b>&lt;2&gt;</b>
Junio C Hamano1a4e8412005-12-27 08:17:231316$ rm -f hello.c
Junio C Hamanoc14e6ad2014-10-31 20:25:531317$ git checkout hello.c <b>&lt;3&gt;</b></code></pre>
Junio C Hamano1a4e8412005-12-27 08:17:231318</div></div>
Junio C Hamano97bcb482010-11-25 03:16:071319<div class="colist arabic"><ol>
Junio C Hamanoc8d88c22006-04-29 07:02:011320<li>
1321<p>
1322switch branch
1323</p>
1324</li>
1325<li>
1326<p>
Junio C Hamano57053932009-03-11 08:48:321327take a file out of another commit
Junio C Hamanoc8d88c22006-04-29 07:02:011328</p>
1329</li>
1330<li>
1331<p>
Junio C Hamanob4a9ede2009-04-08 07:36:321332restore hello.c from the index
Junio C Hamanoc8d88c22006-04-29 07:02:011333</p>
Junio C Hamano693e7092012-09-12 22:56:531334<div class="paragraph"><p>If you want to check out <em>all</em> C source files out of the index,
1335you can say</p></div>
1336<div class="listingblock">
1337<div class="content">
Junio C Hamanoc14e6ad2014-10-31 20:25:531338<pre><code>$ git checkout -- '*.c'</code></pre>
Junio C Hamano693e7092012-09-12 22:56:531339</div></div>
Junio C Hamanoc14e6ad2014-10-31 20:25:531340<div class="paragraph"><p>Note the quotes around <code>*.c</code>. The file <code>hello.c</code> will also be
Junio C Hamano693e7092012-09-12 22:56:531341checked out, even though it is no longer in the working tree,
1342because the file globbing is used to match entries in the index
1343(not in the working tree by the shell).</p></div>
Junio C Hamanoc14e6ad2014-10-31 20:25:531344<div class="paragraph"><p>If you have an unfortunate branch that is named <code>hello.c</code>, this
Junio C Hamanoc8d88c22006-04-29 07:02:011345step would be confused as an instruction to switch to that branch.
Junio C Hamanoba4b9282008-07-06 05:20:311346You should instead write:</p></div>
Junio C Hamano1a4e8412005-12-27 08:17:231347<div class="listingblock">
1348<div class="content">
Junio C Hamanoc14e6ad2014-10-31 20:25:531349<pre><code>$ git checkout -- hello.c</code></pre>
Junio C Hamano1a4e8412005-12-27 08:17:231350</div></div>
Junio C Hamano74e8a2d2006-01-14 03:58:411351</li>
Junio C Hamanoba4b9282008-07-06 05:20:311352</ol></div>
Junio C Hamanoc8d88c22006-04-29 07:02:011353</li>
Junio C Hamano74e8a2d2006-01-14 03:58:411354<li>
1355<p>
Junio C Hamano57053932009-03-11 08:48:321356After working in the wrong branch, switching to the correct
Junio C Hamano2b135272006-03-18 07:45:421357branch would be done using:
Junio C Hamano74e8a2d2006-01-14 03:58:411358</p>
1359<div class="listingblock">
1360<div class="content">
Junio C Hamanoc14e6ad2014-10-31 20:25:531361<pre><code>$ git checkout mytopic</code></pre>
Junio C Hamano74e8a2d2006-01-14 03:58:411362</div></div>
Junio C Hamano97bcb482010-11-25 03:16:071363<div class="paragraph"><p>However, your "wrong" branch and correct "mytopic" branch may
Junio C Hamano57053932009-03-11 08:48:321364differ in files that you have modified locally, in which case
Junio C Hamanoba4b9282008-07-06 05:20:311365the above checkout would fail like this:</p></div>
Junio C Hamano74e8a2d2006-01-14 03:58:411366<div class="listingblock">
1367<div class="content">
Junio C Hamanoc14e6ad2014-10-31 20:25:531368<pre><code>$ git checkout mytopic
1369error: You have local changes to 'frotz'; not switching branches.</code></pre>
Junio C Hamano74e8a2d2006-01-14 03:58:411370</div></div>
Junio C Hamanoc14e6ad2014-10-31 20:25:531371<div class="paragraph"><p>You can give the <code>-m</code> flag to the command, which would try a
Junio C Hamanoba4b9282008-07-06 05:20:311372three-way merge:</p></div>
Junio C Hamano74e8a2d2006-01-14 03:58:411373<div class="listingblock">
1374<div class="content">
Junio C Hamanoc14e6ad2014-10-31 20:25:531375<pre><code>$ git checkout -m mytopic
1376Auto-merging frotz</code></pre>
Junio C Hamano74e8a2d2006-01-14 03:58:411377</div></div>
Junio C Hamano97bcb482010-11-25 03:16:071378<div class="paragraph"><p>After this three-way merge, the local modifications are <em>not</em>
Junio C Hamanoc14e6ad2014-10-31 20:25:531379registered in your index file, so <code>git diff</code> would show you what
Junio C Hamanoba4b9282008-07-06 05:20:311380changes you made since the tip of the new branch.</p></div>
Junio C Hamano74e8a2d2006-01-14 03:58:411381</li>
1382<li>
1383<p>
1384When a merge conflict happens during switching branches with
Junio C Hamanoc14e6ad2014-10-31 20:25:531385the <code>-m</code> option, you would see something like this:
Junio C Hamano74e8a2d2006-01-14 03:58:411386</p>
1387<div class="listingblock">
1388<div class="content">
Junio C Hamanoc14e6ad2014-10-31 20:25:531389<pre><code>$ git checkout -m mytopic
Junio C Hamano74e8a2d2006-01-14 03:58:411390Auto-merging frotz
Junio C Hamano74e8a2d2006-01-14 03:58:411391ERROR: Merge conflict in frotz
Junio C Hamanoc14e6ad2014-10-31 20:25:531392fatal: merge program failed</code></pre>
Junio C Hamano74e8a2d2006-01-14 03:58:411393</div></div>
Junio C Hamanoc14e6ad2014-10-31 20:25:531394<div class="paragraph"><p>At this point, <code>git diff</code> shows the changes cleanly merged as in
Junio C Hamano74e8a2d2006-01-14 03:58:411395the previous example, as well as the changes in the conflicted
1396files. Edit and resolve the conflict and mark it resolved with
Junio C Hamanoc14e6ad2014-10-31 20:25:531397<code>git add</code> as usual:</p></div>
Junio C Hamano74e8a2d2006-01-14 03:58:411398<div class="listingblock">
1399<div class="content">
Junio C Hamanoc14e6ad2014-10-31 20:25:531400<pre><code>$ edit frotz
1401$ git add frotz</code></pre>
Junio C Hamano74e8a2d2006-01-14 03:58:411402</div></div>
1403</li>
Junio C Hamanoba4b9282008-07-06 05:20:311404</ol></div>
Junio C Hamano1a4e8412005-12-27 08:17:231405</div>
Junio C Hamano9d971152012-12-19 00:43:111406</div>
1407<div class="sect1">
Junio C Hamanoba4b9282008-07-06 05:20:311408<h2 id="_git">GIT</h2>
Junio C Hamano1a4e8412005-12-27 08:17:231409<div class="sectionbody">
Junio C Hamanoa28a9202012-06-21 07:08:231410<div class="paragraph"><p>Part of the <a href="git.html">git(1)</a> suite</p></div>
Junio C Hamano1a4e8412005-12-27 08:17:231411</div>
Junio C Hamano7bd050f2011-09-22 06:32:221412</div>
Junio C Hamano9d971152012-12-19 00:43:111413</div>
Junio C Hamano7bd050f2011-09-22 06:32:221414<div id="footnotes"><hr /></div>
Junio C Hamano1a4e8412005-12-27 08:17:231415<div id="footer">
1416<div id="footer-text">
Junio C Hamanoad70bf02016-09-26 23:44:271417Last updated 2016-09-26 16:43:51 PDT
Junio C Hamano1a4e8412005-12-27 08:17:231418</div>
1419</div>
1420</body>
1421</html>