"Fossies" - the Fresh Open Source Software Archive

Member "git-checkout.html" (15 Dec 2018, 43482 Bytes) of package /linux/misc/git-htmldocs-2.20.1.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) HTML source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 <?xml version="1.0" encoding="UTF-8"?>
    2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
    3     "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
    4 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
    5 <head>
    6 <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" />
    7 <meta name="generator" content="AsciiDoc 8.6.10" />
    8 <title>git-checkout(1)</title>
    9 <style type="text/css">
   10 /* Shared CSS for AsciiDoc xhtml11 and html5 backends */
   11 
   12 /* Default font. */
   13 body {
   14   font-family: Georgia,serif;
   15 }
   16 
   17 /* Title font. */
   18 h1, h2, h3, h4, h5, h6,
   19 div.title, caption.title,
   20 thead, p.table.header,
   21 #toctitle,
   22 #author, #revnumber, #revdate, #revremark,
   23 #footer {
   24   font-family: Arial,Helvetica,sans-serif;
   25 }
   26 
   27 body {
   28   margin: 1em 5% 1em 5%;
   29 }
   30 
   31 a {
   32   color: blue;
   33   text-decoration: underline;
   34 }
   35 a:visited {
   36   color: fuchsia;
   37 }
   38 
   39 em {
   40   font-style: italic;
   41   color: navy;
   42 }
   43 
   44 strong {
   45   font-weight: bold;
   46   color: #083194;
   47 }
   48 
   49 h1, h2, h3, h4, h5, h6 {
   50   color: #527bbd;
   51   margin-top: 1.2em;
   52   margin-bottom: 0.5em;
   53   line-height: 1.3;
   54 }
   55 
   56 h1, h2, h3 {
   57   border-bottom: 2px solid silver;
   58 }
   59 h2 {
   60   padding-top: 0.5em;
   61 }
   62 h3 {
   63   float: left;
   64 }
   65 h3 + * {
   66   clear: left;
   67 }
   68 h5 {
   69   font-size: 1.0em;
   70 }
   71 
   72 div.sectionbody {
   73   margin-left: 0;
   74 }
   75 
   76 hr {
   77   border: 1px solid silver;
   78 }
   79 
   80 p {
   81   margin-top: 0.5em;
   82   margin-bottom: 0.5em;
   83 }
   84 
   85 ul, ol, li > p {
   86   margin-top: 0;
   87 }
   88 ul > li     { color: #aaa; }
   89 ul > li > * { color: black; }
   90 
   91 .monospaced, code, pre {
   92   font-family: "Courier New", Courier, monospace;
   93   font-size: inherit;
   94   color: navy;
   95   padding: 0;
   96   margin: 0;
   97 }
   98 pre {
   99   white-space: pre-wrap;
  100 }
  101 
  102 #author {
  103   color: #527bbd;
  104   font-weight: bold;
  105   font-size: 1.1em;
  106 }
  107 #email {
  108 }
  109 #revnumber, #revdate, #revremark {
  110 }
  111 
  112 #footer {
  113   font-size: small;
  114   border-top: 2px solid silver;
  115   padding-top: 0.5em;
  116   margin-top: 4.0em;
  117 }
  118 #footer-text {
  119   float: left;
  120   padding-bottom: 0.5em;
  121 }
  122 #footer-badges {
  123   float: right;
  124   padding-bottom: 0.5em;
  125 }
  126 
  127 #preamble {
  128   margin-top: 1.5em;
  129   margin-bottom: 1.5em;
  130 }
  131 div.imageblock, div.exampleblock, div.verseblock,
  132 div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock,
  133 div.admonitionblock {
  134   margin-top: 1.0em;
  135   margin-bottom: 1.5em;
  136 }
  137 div.admonitionblock {
  138   margin-top: 2.0em;
  139   margin-bottom: 2.0em;
  140   margin-right: 10%;
  141   color: #606060;
  142 }
  143 
  144 div.content { /* Block element content. */
  145   padding: 0;
  146 }
  147 
  148 /* Block element titles. */
  149 div.title, caption.title {
  150   color: #527bbd;
  151   font-weight: bold;
  152   text-align: left;
  153   margin-top: 1.0em;
  154   margin-bottom: 0.5em;
  155 }
  156 div.title + * {
  157   margin-top: 0;
  158 }
  159 
  160 td div.title:first-child {
  161   margin-top: 0.0em;
  162 }
  163 div.content div.title:first-child {
  164   margin-top: 0.0em;
  165 }
  166 div.content + div.title {
  167   margin-top: 0.0em;
  168 }
  169 
  170 div.sidebarblock > div.content {
  171   background: #ffffee;
  172   border: 1px solid #dddddd;
  173   border-left: 4px solid #f0f0f0;
  174   padding: 0.5em;
  175 }
  176 
  177 div.listingblock > div.content {
  178   border: 1px solid #dddddd;
  179   border-left: 5px solid #f0f0f0;
  180   background: #f8f8f8;
  181   padding: 0.5em;
  182 }
  183 
  184 div.quoteblock, div.verseblock {
  185   padding-left: 1.0em;
  186   margin-left: 1.0em;
  187   margin-right: 10%;
  188   border-left: 5px solid #f0f0f0;
  189   color: #888;
  190 }
  191 
  192 div.quoteblock > div.attribution {
  193   padding-top: 0.5em;
  194   text-align: right;
  195 }
  196 
  197 div.verseblock > pre.content {
  198   font-family: inherit;
  199   font-size: inherit;
  200 }
  201 div.verseblock > div.attribution {
  202   padding-top: 0.75em;
  203   text-align: left;
  204 }
  205 /* DEPRECATED: Pre version 8.2.7 verse style literal block. */
  206 div.verseblock + div.attribution {
  207   text-align: left;
  208 }
  209 
  210 div.admonitionblock .icon {
  211   vertical-align: top;
  212   font-size: 1.1em;
  213   font-weight: bold;
  214   text-decoration: underline;
  215   color: #527bbd;
  216   padding-right: 0.5em;
  217 }
  218 div.admonitionblock td.content {
  219   padding-left: 0.5em;
  220   border-left: 3px solid #dddddd;
  221 }
  222 
  223 div.exampleblock > div.content {
  224   border-left: 3px solid #dddddd;
  225   padding-left: 0.5em;
  226 }
  227 
  228 div.imageblock div.content { padding-left: 0; }
  229 span.image img { border-style: none; vertical-align: text-bottom; }
  230 a.image:visited { color: white; }
  231 
  232 dl {
  233   margin-top: 0.8em;
  234   margin-bottom: 0.8em;
  235 }
  236 dt {
  237   margin-top: 0.5em;
  238   margin-bottom: 0;
  239   font-style: normal;
  240   color: navy;
  241 }
  242 dd > *:first-child {
  243   margin-top: 0.1em;
  244 }
  245 
  246 ul, ol {
  247     list-style-position: outside;
  248 }
  249 ol.arabic {
  250   list-style-type: decimal;
  251 }
  252 ol.loweralpha {
  253   list-style-type: lower-alpha;
  254 }
  255 ol.upperalpha {
  256   list-style-type: upper-alpha;
  257 }
  258 ol.lowerroman {
  259   list-style-type: lower-roman;
  260 }
  261 ol.upperroman {
  262   list-style-type: upper-roman;
  263 }
  264 
  265 div.compact ul, div.compact ol,
  266 div.compact p, div.compact p,
  267 div.compact div, div.compact div {
  268   margin-top: 0.1em;
  269   margin-bottom: 0.1em;
  270 }
  271 
  272 tfoot {
  273   font-weight: bold;
  274 }
  275 td > div.verse {
  276   white-space: pre;
  277 }
  278 
  279 div.hdlist {
  280   margin-top: 0.8em;
  281   margin-bottom: 0.8em;
  282 }
  283 div.hdlist tr {
  284   padding-bottom: 15px;
  285 }
  286 dt.hdlist1.strong, td.hdlist1.strong {
  287   font-weight: bold;
  288 }
  289 td.hdlist1 {
  290   vertical-align: top;
  291   font-style: normal;
  292   padding-right: 0.8em;
  293   color: navy;
  294 }
  295 td.hdlist2 {
  296   vertical-align: top;
  297 }
  298 div.hdlist.compact tr {
  299   margin: 0;
  300   padding-bottom: 0;
  301 }
  302 
  303 .comment {
  304   background: yellow;
  305 }
  306 
  307 .footnote, .footnoteref {
  308   font-size: 0.8em;
  309 }
  310 
  311 span.footnote, span.footnoteref {
  312   vertical-align: super;
  313 }
  314 
  315 #footnotes {
  316   margin: 20px 0 20px 0;
  317   padding: 7px 0 0 0;
  318 }
  319 
  320 #footnotes div.footnote {
  321   margin: 0 0 5px 0;
  322 }
  323 
  324 #footnotes hr {
  325   border: none;
  326   border-top: 1px solid silver;
  327   height: 1px;
  328   text-align: left;
  329   margin-left: 0;
  330   width: 20%;
  331   min-width: 100px;
  332 }
  333 
  334 div.colist td {
  335   padding-right: 0.5em;
  336   padding-bottom: 0.3em;
  337   vertical-align: top;
  338 }
  339 div.colist td img {
  340   margin-top: 0.3em;
  341 }
  342 
  343 @media print {
  344   #footer-badges { display: none; }
  345 }
  346 
  347 #toc {
  348   margin-bottom: 2.5em;
  349 }
  350 
  351 #toctitle {
  352   color: #527bbd;
  353   font-size: 1.1em;
  354   font-weight: bold;
  355   margin-top: 1.0em;
  356   margin-bottom: 0.1em;
  357 }
  358 
  359 div.toclevel0, div.toclevel1, div.toclevel2, div.toclevel3, div.toclevel4 {
  360   margin-top: 0;
  361   margin-bottom: 0;
  362 }
  363 div.toclevel2 {
  364   margin-left: 2em;
  365   font-size: 0.9em;
  366 }
  367 div.toclevel3 {
  368   margin-left: 4em;
  369   font-size: 0.9em;
  370 }
  371 div.toclevel4 {
  372   margin-left: 6em;
  373   font-size: 0.9em;
  374 }
  375 
  376 span.aqua { color: aqua; }
  377 span.black { color: black; }
  378 span.blue { color: blue; }
  379 span.fuchsia { color: fuchsia; }
  380 span.gray { color: gray; }
  381 span.green { color: green; }
  382 span.lime { color: lime; }
  383 span.maroon { color: maroon; }
  384 span.navy { color: navy; }
  385 span.olive { color: olive; }
  386 span.purple { color: purple; }
  387 span.red { color: red; }
  388 span.silver { color: silver; }
  389 span.teal { color: teal; }
  390 span.white { color: white; }
  391 span.yellow { color: yellow; }
  392 
  393 span.aqua-background { background: aqua; }
  394 span.black-background { background: black; }
  395 span.blue-background { background: blue; }
  396 span.fuchsia-background { background: fuchsia; }
  397 span.gray-background { background: gray; }
  398 span.green-background { background: green; }
  399 span.lime-background { background: lime; }
  400 span.maroon-background { background: maroon; }
  401 span.navy-background { background: navy; }
  402 span.olive-background { background: olive; }
  403 span.purple-background { background: purple; }
  404 span.red-background { background: red; }
  405 span.silver-background { background: silver; }
  406 span.teal-background { background: teal; }
  407 span.white-background { background: white; }
  408 span.yellow-background { background: yellow; }
  409 
  410 span.big { font-size: 2em; }
  411 span.small { font-size: 0.6em; }
  412 
  413 span.underline { text-decoration: underline; }
  414 span.overline { text-decoration: overline; }
  415 span.line-through { text-decoration: line-through; }
  416 
  417 div.unbreakable { page-break-inside: avoid; }
  418 
  419 
  420 /*
  421  * xhtml11 specific
  422  *
  423  * */
  424 
  425 div.tableblock {
  426   margin-top: 1.0em;
  427   margin-bottom: 1.5em;
  428 }
  429 div.tableblock > table {
  430   border: 3px solid #527bbd;
  431 }
  432 thead, p.table.header {
  433   font-weight: bold;
  434   color: #527bbd;
  435 }
  436 p.table {
  437   margin-top: 0;
  438 }
  439 /* Because the table frame attribute is overriden by CSS in most browsers. */
  440 div.tableblock > table[frame="void"] {
  441   border-style: none;
  442 }
  443 div.tableblock > table[frame="hsides"] {
  444   border-left-style: none;
  445   border-right-style: none;
  446 }
  447 div.tableblock > table[frame="vsides"] {
  448   border-top-style: none;
  449   border-bottom-style: none;
  450 }
  451 
  452 
  453 /*
  454  * html5 specific
  455  *
  456  * */
  457 
  458 table.tableblock {
  459   margin-top: 1.0em;
  460   margin-bottom: 1.5em;
  461 }
  462 thead, p.tableblock.header {
  463   font-weight: bold;
  464   color: #527bbd;
  465 }
  466 p.tableblock {
  467   margin-top: 0;
  468 }
  469 table.tableblock {
  470   border-width: 3px;
  471   border-spacing: 0px;
  472   border-style: solid;
  473   border-color: #527bbd;
  474   border-collapse: collapse;
  475 }
  476 th.tableblock, td.tableblock {
  477   border-width: 1px;
  478   padding: 4px;
  479   border-style: solid;
  480   border-color: #527bbd;
  481 }
  482 
  483 table.tableblock.frame-topbot {
  484   border-left-style: hidden;
  485   border-right-style: hidden;
  486 }
  487 table.tableblock.frame-sides {
  488   border-top-style: hidden;
  489   border-bottom-style: hidden;
  490 }
  491 table.tableblock.frame-none {
  492   border-style: hidden;
  493 }
  494 
  495 th.tableblock.halign-left, td.tableblock.halign-left {
  496   text-align: left;
  497 }
  498 th.tableblock.halign-center, td.tableblock.halign-center {
  499   text-align: center;
  500 }
  501 th.tableblock.halign-right, td.tableblock.halign-right {
  502   text-align: right;
  503 }
  504 
  505 th.tableblock.valign-top, td.tableblock.valign-top {
  506   vertical-align: top;
  507 }
  508 th.tableblock.valign-middle, td.tableblock.valign-middle {
  509   vertical-align: middle;
  510 }
  511 th.tableblock.valign-bottom, td.tableblock.valign-bottom {
  512   vertical-align: bottom;
  513 }
  514 
  515 
  516 /*
  517  * manpage specific
  518  *
  519  * */
  520 
  521 body.manpage h1 {
  522   padding-top: 0.5em;
  523   padding-bottom: 0.5em;
  524   border-top: 2px solid silver;
  525   border-bottom: 2px solid silver;
  526 }
  527 body.manpage h2 {
  528   border-style: none;
  529 }
  530 body.manpage div.sectionbody {
  531   margin-left: 3em;
  532 }
  533 
  534 @media print {
  535   body.manpage div#toc { display: none; }
  536 }
  537 
  538 
  539 </style>
  540 <script type="text/javascript">
  541 /*<![CDATA[*/
  542 var asciidoc = {  // Namespace.
  543 
  544 /////////////////////////////////////////////////////////////////////
  545 // Table Of Contents generator
  546 /////////////////////////////////////////////////////////////////////
  547 
  548 /* Author: Mihai Bazon, September 2002
  549  * http://students.infoiasi.ro/~mishoo
  550  *
  551  * Table Of Content generator
  552  * Version: 0.4
  553  *
  554  * Feel free to use this script under the terms of the GNU General Public
  555  * License, as long as you do not remove or alter this notice.
  556  */
  557 
  558  /* modified by Troy D. Hanson, September 2006. License: GPL */
  559  /* modified by Stuart Rackham, 2006, 2009. License: GPL */
  560 
  561 // toclevels = 1..4.
  562 toc: function (toclevels) {
  563 
  564   function getText(el) {
  565     var text = "";
  566     for (var i = el.firstChild; i != null; i = i.nextSibling) {
  567       if (i.nodeType == 3 /* Node.TEXT_NODE */) // IE doesn't speak constants.
  568         text += i.data;
  569       else if (i.firstChild != null)
  570         text += getText(i);
  571     }
  572     return text;
  573   }
  574 
  575   function TocEntry(el, text, toclevel) {
  576     this.element = el;
  577     this.text = text;
  578     this.toclevel = toclevel;
  579   }
  580 
  581   function tocEntries(el, toclevels) {
  582     var result = new Array;
  583     var re = new RegExp('[hH]([1-'+(toclevels+1)+'])');
  584     // Function that scans the DOM tree for header elements (the DOM2
  585     // nodeIterator API would be a better technique but not supported by all
  586     // browsers).
  587     var iterate = function (el) {
  588       for (var i = el.firstChild; i != null; i = i.nextSibling) {
  589         if (i.nodeType == 1 /* Node.ELEMENT_NODE */) {
  590           var mo = re.exec(i.tagName);
  591           if (mo && (i.getAttribute("class") || i.getAttribute("className")) != "float") {
  592             result[result.length] = new TocEntry(i, getText(i), mo[1]-1);
  593           }
  594           iterate(i);
  595         }
  596       }
  597     }
  598     iterate(el);
  599     return result;
  600   }
  601 
  602   var toc = document.getElementById("toc");
  603   if (!toc) {
  604     return;
  605   }
  606 
  607   // Delete existing TOC entries in case we're reloading the TOC.
  608   var tocEntriesToRemove = [];
  609   var i;
  610   for (i = 0; i < toc.childNodes.length; i++) {
  611     var entry = toc.childNodes[i];
  612     if (entry.nodeName.toLowerCase() == 'div'
  613      && entry.getAttribute("class")
  614      && entry.getAttribute("class").match(/^toclevel/))
  615       tocEntriesToRemove.push(entry);
  616   }
  617   for (i = 0; i < tocEntriesToRemove.length; i++) {
  618     toc.removeChild(tocEntriesToRemove[i]);
  619   }
  620 
  621   // Rebuild TOC entries.
  622   var entries = tocEntries(document.getElementById("content"), toclevels);
  623   for (var i = 0; i < entries.length; ++i) {
  624     var entry = entries[i];
  625     if (entry.element.id == "")
  626       entry.element.id = "_toc_" + i;
  627     var a = document.createElement("a");
  628     a.href = "#" + entry.element.id;
  629     a.appendChild(document.createTextNode(entry.text));
  630     var div = document.createElement("div");
  631     div.appendChild(a);
  632     div.className = "toclevel" + entry.toclevel;
  633     toc.appendChild(div);
  634   }
  635   if (entries.length == 0)
  636     toc.parentNode.removeChild(toc);
  637 },
  638 
  639 
  640 /////////////////////////////////////////////////////////////////////
  641 // Footnotes generator
  642 /////////////////////////////////////////////////////////////////////
  643 
  644 /* Based on footnote generation code from:
  645  * http://www.brandspankingnew.net/archive/2005/07/format_footnote.html
  646  */
  647 
  648 footnotes: function () {
  649   // Delete existing footnote entries in case we're reloading the footnodes.
  650   var i;
  651   var noteholder = document.getElementById("footnotes");
  652   if (!noteholder) {
  653     return;
  654   }
  655   var entriesToRemove = [];
  656   for (i = 0; i < noteholder.childNodes.length; i++) {
  657     var entry = noteholder.childNodes[i];
  658     if (entry.nodeName.toLowerCase() == 'div' && entry.getAttribute("class") == "footnote")
  659       entriesToRemove.push(entry);
  660   }
  661   for (i = 0; i < entriesToRemove.length; i++) {
  662     noteholder.removeChild(entriesToRemove[i]);
  663   }
  664 
  665   // Rebuild footnote entries.
  666   var cont = document.getElementById("content");
  667   var spans = cont.getElementsByTagName("span");
  668   var refs = {};
  669   var n = 0;
  670   for (i=0; i<spans.length; i++) {
  671     if (spans[i].className == "footnote") {
  672       n++;
  673       var note = spans[i].getAttribute("data-note");
  674       if (!note) {
  675         // Use [\s\S] in place of . so multi-line matches work.
  676         // Because JavaScript has no s (dotall) regex flag.
  677         note = spans[i].innerHTML.match(/\s*\[([\s\S]*)]\s*/)[1];
  678         spans[i].innerHTML =
  679           "[<a id='_footnoteref_" + n + "' href='#_footnote_" + n +
  680           "' title='View footnote' class='footnote'>" + n + "</a>]";
  681         spans[i].setAttribute("data-note", note);
  682       }
  683       noteholder.innerHTML +=
  684         "<div class='footnote' id='_footnote_" + n + "'>" +
  685         "<a href='#_footnoteref_" + n + "' title='Return to text'>" +
  686         n + "</a>. " + note + "</div>";
  687       var id =spans[i].getAttribute("id");
  688       if (id != null) refs["#"+id] = n;
  689     }
  690   }
  691   if (n == 0)
  692     noteholder.parentNode.removeChild(noteholder);
  693   else {
  694     // Process footnoterefs.
  695     for (i=0; i<spans.length; i++) {
  696       if (spans[i].className == "footnoteref") {
  697         var href = spans[i].getElementsByTagName("a")[0].getAttribute("href");
  698         href = href.match(/#.*/)[0];  // Because IE return full URL.
  699         n = refs[href];
  700         spans[i].innerHTML =
  701           "[<a href='#_footnote_" + n +
  702           "' title='View footnote' class='footnote'>" + n + "</a>]";
  703       }
  704     }
  705   }
  706 },
  707 
  708 install: function(toclevels) {
  709   var timerId;
  710 
  711   function reinstall() {
  712     asciidoc.footnotes();
  713     if (toclevels) {
  714       asciidoc.toc(toclevels);
  715     }
  716   }
  717 
  718   function reinstallAndRemoveTimer() {
  719     clearInterval(timerId);
  720     reinstall();
  721   }
  722 
  723   timerId = setInterval(reinstall, 500);
  724   if (document.addEventListener)
  725     document.addEventListener("DOMContentLoaded", reinstallAndRemoveTimer, false);
  726   else
  727     window.onload = reinstallAndRemoveTimer;
  728 }
  729 
  730 }
  731 asciidoc.install();
  732 /*]]>*/
  733 </script>
  734 </head>
  735 <body class="manpage">
  736 <div id="header">
  737 <h1>
  738 git-checkout(1) Manual Page
  739 </h1>
  740 <h2>NAME</h2>
  741 <div class="sectionbody">
  742 <p>git-checkout -
  743    Switch branches or restore working tree files
  744 </p>
  745 </div>
  746 </div>
  747 <div id="content">
  748 <div class="sect1">
  749 <h2 id="_synopsis">SYNOPSIS</h2>
  750 <div class="sectionbody">
  751 <div class="verseblock">
  752 <pre class="content"><em>git checkout</em> [-q] [-f] [-m] [&lt;branch&gt;]
  753 <em>git checkout</em> [-q] [-f] [-m] --detach [&lt;branch&gt;]
  754 <em>git checkout</em> [-q] [-f] [-m] [--detach] &lt;commit&gt;
  755 <em>git checkout</em> [-q] [-f] [-m] [[-b|-B|--orphan] &lt;new_branch&gt;] [&lt;start_point&gt;]
  756 <em>git checkout</em> [-f|--ours|--theirs|-m|--conflict=&lt;style&gt;] [&lt;tree-ish&gt;] [--] &lt;paths&gt;&#8230;
  757 <em>git checkout</em> [&lt;tree-ish&gt;] [--] &lt;pathspec&gt;&#8230;
  758 <em>git checkout</em> (-p|--patch) [&lt;tree-ish&gt;] [--] [&lt;paths&gt;&#8230;]</pre>
  759 <div class="attribution">
  760 </div></div>
  761 </div>
  762 </div>
  763 <div class="sect1">
  764 <h2 id="_description">DESCRIPTION</h2>
  765 <div class="sectionbody">
  766 <div class="paragraph"><p>Updates files in the working tree to match the version in the index
  767 or the specified tree.  If no paths are given, <em>git checkout</em> will
  768 also update <code>HEAD</code> to set the specified branch as the current
  769 branch.</p></div>
  770 <div class="dlist"><dl>
  771 <dt class="hdlist1">
  772 <em>git checkout</em> &lt;branch&gt;
  773 </dt>
  774 <dd>
  775 <p>
  776         To prepare for working on &lt;branch&gt;, switch to it by updating
  777         the index and the files in the working tree, and by pointing
  778         HEAD at the branch. Local modifications to the files in the
  779         working tree are kept, so that they can be committed to the
  780         &lt;branch&gt;.
  781 </p>
  782 <div class="paragraph"><p>If &lt;branch&gt; is not found but there does exist a tracking branch in
  783 exactly one remote (call it &lt;remote&gt;) with a matching name, treat as
  784 equivalent to</p></div>
  785 <div class="listingblock">
  786 <div class="content">
  787 <pre><code>$ git checkout -b &lt;branch&gt; --track &lt;remote&gt;/&lt;branch&gt;</code></pre>
  788 </div></div>
  789 <div class="paragraph"><p>If the branch exists in multiple remotes and one of them is named by
  790 the <code>checkout.defaultRemote</code> configuration variable, we&#8217;ll use that
  791 one for the purposes of disambiguation, even if the <code>&lt;branch&gt;</code> isn&#8217;t
  792 unique across all remotes. Set it to
  793 e.g. <code>checkout.defaultRemote=origin</code> to always checkout remote
  794 branches from there if <code>&lt;branch&gt;</code> is ambiguous but exists on the
  795 <em>origin</em> remote. See also <code>checkout.defaultRemote</code> in
  796 <a href="git-config.html">git-config(1)</a>.</p></div>
  797 <div class="paragraph"><p>You could omit &lt;branch&gt;, in which case the command degenerates to
  798 "check out the current branch", which is a glorified no-op with
  799 rather expensive side-effects to show only the tracking information,
  800 if exists, for the current branch.</p></div>
  801 </dd>
  802 <dt class="hdlist1">
  803 <em>git checkout</em> -b|-B &lt;new_branch&gt; [&lt;start point&gt;]
  804 </dt>
  805 <dd>
  806 <p>
  807         Specifying <code>-b</code> causes a new branch to be created as if
  808         <a href="git-branch.html">git-branch(1)</a> were called and then checked out.  In
  809         this case you can use the <code>--track</code> or <code>--no-track</code> options,
  810         which will be passed to <em>git branch</em>.  As a convenience,
  811         <code>--track</code> without <code>-b</code> implies branch creation; see the
  812         description of <code>--track</code> below.
  813 </p>
  814 <div class="paragraph"><p>If <code>-B</code> is given, &lt;new_branch&gt; is created if it doesn&#8217;t exist; otherwise, it
  815 is reset. This is the transactional equivalent of</p></div>
  816 <div class="listingblock">
  817 <div class="content">
  818 <pre><code>$ git branch -f &lt;branch&gt; [&lt;start point&gt;]
  819 $ git checkout &lt;branch&gt;</code></pre>
  820 </div></div>
  821 <div class="paragraph"><p>that is to say, the branch is not reset/created unless "git checkout" is
  822 successful.</p></div>
  823 </dd>
  824 <dt class="hdlist1">
  825 <em>git checkout</em> --detach [&lt;branch&gt;]
  826 </dt>
  827 <dt class="hdlist1">
  828 <em>git checkout</em> [--detach] &lt;commit&gt;
  829 </dt>
  830 <dd>
  831 <p>
  832         Prepare to work on top of &lt;commit&gt;, by detaching HEAD at it
  833         (see "DETACHED HEAD" section), and updating the index and the
  834         files in the working tree.  Local modifications to the files
  835         in the working tree are kept, so that the resulting working
  836         tree will be the state recorded in the commit plus the local
  837         modifications.
  838 </p>
  839 <div class="paragraph"><p>When the &lt;commit&gt; argument is a branch name, the <code>--detach</code> option can
  840 be used to detach HEAD at the tip of the branch (<code>git checkout
  841 &lt;branch&gt;</code> would check out that branch without detaching HEAD).</p></div>
  842 <div class="paragraph"><p>Omitting &lt;branch&gt; detaches HEAD at the tip of the current branch.</p></div>
  843 </dd>
  844 <dt class="hdlist1">
  845 <em>git checkout</em> [&lt;tree-ish&gt;] [--] &lt;pathspec&gt;&#8230;
  846 </dt>
  847 <dd>
  848 <p>
  849         Overwrite paths in the working tree by replacing with the
  850         contents in the index or in the &lt;tree-ish&gt; (most often a
  851         commit).  When a &lt;tree-ish&gt; is given, the paths that
  852         match the &lt;pathspec&gt; are updated both in the index and in
  853         the working tree.
  854 </p>
  855 <div class="paragraph"><p>The index may contain unmerged entries because of a previous failed merge.
  856 By default, if you try to check out such an entry from the index, the
  857 checkout operation will fail and nothing will be checked out.
  858 Using <code>-f</code> will ignore these unmerged entries.  The contents from a
  859 specific side of the merge can be checked out of the index by
  860 using <code>--ours</code> or <code>--theirs</code>.  With <code>-m</code>, changes made to the working tree
  861 file can be discarded to re-create the original conflicted merge result.</p></div>
  862 </dd>
  863 <dt class="hdlist1">
  864 <em>git checkout</em> (-p|--patch) [&lt;tree-ish&gt;] [--] [&lt;pathspec&gt;&#8230;]
  865 </dt>
  866 <dd>
  867 <p>
  868         This is similar to the "check out paths to the working tree
  869         from either the index or from a tree-ish" mode described
  870         above, but lets you use the interactive interface to show
  871         the "diff" output and choose which hunks to use in the
  872         result.  See below for the description of <code>--patch</code> option.
  873 </p>
  874 </dd>
  875 </dl></div>
  876 </div>
  877 </div>
  878 <div class="sect1">
  879 <h2 id="_options">OPTIONS</h2>
  880 <div class="sectionbody">
  881 <div class="dlist"><dl>
  882 <dt class="hdlist1">
  883 -q
  884 </dt>
  885 <dt class="hdlist1">
  886 --quiet
  887 </dt>
  888 <dd>
  889 <p>
  890         Quiet, suppress feedback messages.
  891 </p>
  892 </dd>
  893 <dt class="hdlist1">
  894 --[no-]progress
  895 </dt>
  896 <dd>
  897 <p>
  898         Progress status is reported on the standard error stream
  899         by default when it is attached to a terminal, unless <code>--quiet</code>
  900         is specified. This flag enables progress reporting even if not
  901         attached to a terminal, regardless of <code>--quiet</code>.
  902 </p>
  903 </dd>
  904 <dt class="hdlist1">
  905 -f
  906 </dt>
  907 <dt class="hdlist1">
  908 --force
  909 </dt>
  910 <dd>
  911 <p>
  912         When switching branches, proceed even if the index or the
  913         working tree differs from HEAD.  This is used to throw away
  914         local changes.
  915 </p>
  916 <div class="paragraph"><p>When checking out paths from the index, do not fail upon unmerged
  917 entries; instead, unmerged entries are ignored.</p></div>
  918 </dd>
  919 <dt class="hdlist1">
  920 --ours
  921 </dt>
  922 <dt class="hdlist1">
  923 --theirs
  924 </dt>
  925 <dd>
  926 <p>
  927         When checking out paths from the index, check out stage #2
  928         (<em>ours</em>) or #3 (<em>theirs</em>) for unmerged paths.
  929 </p>
  930 <div class="paragraph"><p>Note that during <code>git rebase</code> and <code>git pull --rebase</code>, <em>ours</em> and
  931 <em>theirs</em> may appear swapped; <code>--ours</code> gives the version from the
  932 branch the changes are rebased onto, while <code>--theirs</code> gives the
  933 version from the branch that holds your work that is being rebased.</p></div>
  934 <div class="paragraph"><p>This is because <code>rebase</code> is used in a workflow that treats the
  935 history at the remote as the shared canonical one, and treats the
  936 work done on the branch you are rebasing as the third-party work to
  937 be integrated, and you are temporarily assuming the role of the
  938 keeper of the canonical history during the rebase.  As the keeper of
  939 the canonical history, you need to view the history from the remote
  940 as <code>ours</code> (i.e. "our shared canonical history"), while what you did
  941 on your side branch as <code>theirs</code> (i.e. "one contributor&#8217;s work on top
  942 of it").</p></div>
  943 </dd>
  944 <dt class="hdlist1">
  945 -b &lt;new_branch&gt;
  946 </dt>
  947 <dd>
  948 <p>
  949         Create a new branch named &lt;new_branch&gt; and start it at
  950         &lt;start_point&gt;; see <a href="git-branch.html">git-branch(1)</a> for details.
  951 </p>
  952 </dd>
  953 <dt class="hdlist1">
  954 -B &lt;new_branch&gt;
  955 </dt>
  956 <dd>
  957 <p>
  958         Creates the branch &lt;new_branch&gt; and start it at &lt;start_point&gt;;
  959         if it already exists, then reset it to &lt;start_point&gt;. This is
  960         equivalent to running "git branch" with "-f"; see
  961         <a href="git-branch.html">git-branch(1)</a> for details.
  962 </p>
  963 </dd>
  964 <dt class="hdlist1">
  965 -t
  966 </dt>
  967 <dt class="hdlist1">
  968 --track
  969 </dt>
  970 <dd>
  971 <p>
  972         When creating a new branch, set up "upstream" configuration. See
  973         "--track" in <a href="git-branch.html">git-branch(1)</a> for details.
  974 </p>
  975 <div class="paragraph"><p>If no <code>-b</code> option is given, the name of the new branch will be
  976 derived from the remote-tracking branch, by looking at the local part of
  977 the refspec configured for the corresponding remote, and then stripping
  978 the initial part up to the "*".
  979 This would tell us to use "hack" as the local branch when branching
  980 off of "origin/hack" (or "remotes/origin/hack", or even
  981 "refs/remotes/origin/hack").  If the given name has no slash, or the above
  982 guessing results in an empty name, the guessing is aborted.  You can
  983 explicitly give a name with <code>-b</code> in such a case.</p></div>
  984 </dd>
  985 <dt class="hdlist1">
  986 --no-track
  987 </dt>
  988 <dd>
  989 <p>
  990         Do not set up "upstream" configuration, even if the
  991         branch.autoSetupMerge configuration variable is true.
  992 </p>
  993 </dd>
  994 <dt class="hdlist1">
  995 -l
  996 </dt>
  997 <dd>
  998 <p>
  999         Create the new branch&#8217;s reflog; see <a href="git-branch.html">git-branch(1)</a> for
 1000         details.
 1001 </p>
 1002 </dd>
 1003 <dt class="hdlist1">
 1004 --detach
 1005 </dt>
 1006 <dd>
 1007 <p>
 1008         Rather than checking out a branch to work on it, check out a
 1009         commit for inspection and discardable experiments.
 1010         This is the default behavior of "git checkout &lt;commit&gt;" when
 1011         &lt;commit&gt; is not a branch name.  See the "DETACHED HEAD" section
 1012         below for details.
 1013 </p>
 1014 </dd>
 1015 <dt class="hdlist1">
 1016 --orphan &lt;new_branch&gt;
 1017 </dt>
 1018 <dd>
 1019 <p>
 1020         Create a new <em>orphan</em> branch, named &lt;new_branch&gt;, started from
 1021         &lt;start_point&gt; and switch to it.  The first commit made on this
 1022         new branch will have no parents and it will be the root of a new
 1023         history totally disconnected from all the other branches and
 1024         commits.
 1025 </p>
 1026 <div class="paragraph"><p>The index and the working tree are adjusted as if you had previously run
 1027 "git checkout &lt;start_point&gt;".  This allows you to start a new history
 1028 that records a set of paths similar to &lt;start_point&gt; by easily running
 1029 "git commit -a" to make the root commit.</p></div>
 1030 <div class="paragraph"><p>This can be useful when you want to publish the tree from a commit
 1031 without exposing its full history. You might want to do this to publish
 1032 an open source branch of a project whose current tree is "clean", but
 1033 whose full history contains proprietary or otherwise encumbered bits of
 1034 code.</p></div>
 1035 <div class="paragraph"><p>If you want to start a disconnected history that records a set of paths
 1036 that is totally different from the one of &lt;start_point&gt;, then you should
 1037 clear the index and the working tree right after creating the orphan
 1038 branch by running "git rm -rf ." from the top level of the working tree.
 1039 Afterwards you will be ready to prepare your new files, repopulating the
 1040 working tree, by copying them from elsewhere, extracting a tarball, etc.</p></div>
 1041 </dd>
 1042 <dt class="hdlist1">
 1043 --ignore-skip-worktree-bits
 1044 </dt>
 1045 <dd>
 1046 <p>
 1047         In sparse checkout mode, <code>git checkout -- &lt;paths&gt;</code> would
 1048         update only entries matched by &lt;paths&gt; and sparse patterns
 1049         in $GIT_DIR/info/sparse-checkout. This option ignores
 1050         the sparse patterns and adds back any files in &lt;paths&gt;.
 1051 </p>
 1052 </dd>
 1053 <dt class="hdlist1">
 1054 -m
 1055 </dt>
 1056 <dt class="hdlist1">
 1057 --merge
 1058 </dt>
 1059 <dd>
 1060 <p>
 1061         When switching branches,
 1062         if you have local modifications to one or more files that
 1063         are different between the current branch and the branch to
 1064         which you are switching, the command refuses to switch
 1065         branches in order to preserve your modifications in context.
 1066         However, with this option, a three-way merge between the current
 1067         branch, your working tree contents, and the new branch
 1068         is done, and you will be on the new branch.
 1069 </p>
 1070 <div class="paragraph"><p>When a merge conflict happens, the index entries for conflicting
 1071 paths are left unmerged, and you need to resolve the conflicts
 1072 and mark the resolved paths with <code>git add</code> (or <code>git rm</code> if the merge
 1073 should result in deletion of the path).</p></div>
 1074 <div class="paragraph"><p>When checking out paths from the index, this option lets you recreate
 1075 the conflicted merge in the specified paths.</p></div>
 1076 </dd>
 1077 <dt class="hdlist1">
 1078 --conflict=&lt;style&gt;
 1079 </dt>
 1080 <dd>
 1081 <p>
 1082         The same as --merge option above, but changes the way the
 1083         conflicting hunks are presented, overriding the
 1084         merge.conflictStyle configuration variable.  Possible values are
 1085         "merge" (default) and "diff3" (in addition to what is shown by
 1086         "merge" style, shows the original contents).
 1087 </p>
 1088 </dd>
 1089 <dt class="hdlist1">
 1090 -p
 1091 </dt>
 1092 <dt class="hdlist1">
 1093 --patch
 1094 </dt>
 1095 <dd>
 1096 <p>
 1097         Interactively select hunks in the difference between the
 1098         &lt;tree-ish&gt; (or the index, if unspecified) and the working
 1099         tree.  The chosen hunks are then applied in reverse to the
 1100         working tree (and if a &lt;tree-ish&gt; was specified, the index).
 1101 </p>
 1102 <div class="paragraph"><p>This means that you can use <code>git checkout -p</code> to selectively discard
 1103 edits from your current working tree. See the &#8220;Interactive Mode&#8221;
 1104 section of <a href="git-add.html">git-add(1)</a> to learn how to operate the <code>--patch</code> mode.</p></div>
 1105 </dd>
 1106 <dt class="hdlist1">
 1107 --ignore-other-worktrees
 1108 </dt>
 1109 <dd>
 1110 <p>
 1111         <code>git checkout</code> refuses when the wanted ref is already checked
 1112         out by another worktree. This option makes it check the ref
 1113         out anyway. In other words, the ref can be held by more than one
 1114         worktree.
 1115 </p>
 1116 </dd>
 1117 <dt class="hdlist1">
 1118 --[no-]recurse-submodules
 1119 </dt>
 1120 <dd>
 1121 <p>
 1122         Using --recurse-submodules will update the content of all initialized
 1123         submodules according to the commit recorded in the superproject. If
 1124         local modifications in a submodule would be overwritten the checkout
 1125         will fail unless <code>-f</code> is used. If nothing (or --no-recurse-submodules)
 1126         is used, the work trees of submodules will not be updated.
 1127         Just like <a href="git-submodule.html">git-submodule(1)</a>, this will detach the
 1128         submodules HEAD.
 1129 </p>
 1130 </dd>
 1131 <dt class="hdlist1">
 1132 &lt;branch&gt;
 1133 </dt>
 1134 <dd>
 1135 <p>
 1136         Branch to checkout; if it refers to a branch (i.e., a name that,
 1137         when prepended with "refs/heads/", is a valid ref), then that
 1138         branch is checked out. Otherwise, if it refers to a valid
 1139         commit, your HEAD becomes "detached" and you are no longer on
 1140         any branch (see below for details).
 1141 </p>
 1142 <div class="paragraph"><p>You can use the <code>"@{-N}"</code> syntax to refer to the N-th last
 1143 branch/commit checked out using "git checkout" operation. You may
 1144 also specify <code>-</code> which is synonymous to <code>"@{-1}</code>.</p></div>
 1145 <div class="paragraph"><p>As a special case, you may use <code>"A...B"</code> as a shortcut for the
 1146 merge base of <code>A</code> and <code>B</code> if there is exactly one merge base. You can
 1147 leave out at most one of <code>A</code> and <code>B</code>, in which case it defaults to <code>HEAD</code>.</p></div>
 1148 </dd>
 1149 <dt class="hdlist1">
 1150 &lt;new_branch&gt;
 1151 </dt>
 1152 <dd>
 1153 <p>
 1154         Name for the new branch.
 1155 </p>
 1156 </dd>
 1157 <dt class="hdlist1">
 1158 &lt;start_point&gt;
 1159 </dt>
 1160 <dd>
 1161 <p>
 1162         The name of a commit at which to start the new branch; see
 1163         <a href="git-branch.html">git-branch(1)</a> for details. Defaults to HEAD.
 1164 </p>
 1165 </dd>
 1166 <dt class="hdlist1">
 1167 &lt;tree-ish&gt;
 1168 </dt>
 1169 <dd>
 1170 <p>
 1171         Tree to checkout from (when paths are given). If not specified,
 1172         the index will be used.
 1173 </p>
 1174 </dd>
 1175 </dl></div>
 1176 </div>
 1177 </div>
 1178 <div class="sect1">
 1179 <h2 id="_detached_head">DETACHED HEAD</h2>
 1180 <div class="sectionbody">
 1181 <div class="paragraph"><p>HEAD normally refers to a named branch (e.g. <em>master</em>). Meanwhile, each
 1182 branch refers to a specific commit. Let&#8217;s look at a repo with three
 1183 commits, one of them tagged, and with branch <em>master</em> checked out:</p></div>
 1184 <div class="listingblock">
 1185 <div class="content">
 1186 <pre><code>           HEAD (refers to branch 'master')
 1187             |
 1188             v
 1189 a---b---c  branch 'master' (refers to commit 'c')
 1190     ^
 1191     |
 1192   tag 'v2.0' (refers to commit 'b')</code></pre>
 1193 </div></div>
 1194 <div class="paragraph"><p>When a commit is created in this state, the branch is updated to refer to
 1195 the new commit. Specifically, <em>git commit</em> creates a new commit <em>d</em>, whose
 1196 parent is commit <em>c</em>, and then updates branch <em>master</em> to refer to new
 1197 commit <em>d</em>. HEAD still refers to branch <em>master</em> and so indirectly now refers
 1198 to commit <em>d</em>:</p></div>
 1199 <div class="listingblock">
 1200 <div class="content">
 1201 <pre><code>$ edit; git add; git commit
 1202 
 1203                HEAD (refers to branch 'master')
 1204                 |
 1205                 v
 1206 a---b---c---d  branch 'master' (refers to commit 'd')
 1207     ^
 1208     |
 1209   tag 'v2.0' (refers to commit 'b')</code></pre>
 1210 </div></div>
 1211 <div class="paragraph"><p>It is sometimes useful to be able to checkout a commit that is not at
 1212 the tip of any named branch, or even to create a new commit that is not
 1213 referenced by a named branch. Let&#8217;s look at what happens when we
 1214 checkout commit <em>b</em> (here we show two ways this may be done):</p></div>
 1215 <div class="listingblock">
 1216 <div class="content">
 1217 <pre><code>$ git checkout v2.0  # or
 1218 $ git checkout master^^
 1219 
 1220    HEAD (refers to commit 'b')
 1221     |
 1222     v
 1223 a---b---c---d  branch 'master' (refers to commit 'd')
 1224     ^
 1225     |
 1226   tag 'v2.0' (refers to commit 'b')</code></pre>
 1227 </div></div>
 1228 <div class="paragraph"><p>Notice that regardless of which checkout command we use, HEAD now refers
 1229 directly to commit <em>b</em>. This is known as being in detached HEAD state.
 1230 It means simply that HEAD refers to a specific commit, as opposed to
 1231 referring to a named branch. Let&#8217;s see what happens when we create a commit:</p></div>
 1232 <div class="listingblock">
 1233 <div class="content">
 1234 <pre><code>$ edit; git add; git commit
 1235 
 1236      HEAD (refers to commit 'e')
 1237       |
 1238       v
 1239       e
 1240      /
 1241 a---b---c---d  branch 'master' (refers to commit 'd')
 1242     ^
 1243     |
 1244   tag 'v2.0' (refers to commit 'b')</code></pre>
 1245 </div></div>
 1246 <div class="paragraph"><p>There is now a new commit <em>e</em>, but it is referenced only by HEAD. We can
 1247 of course add yet another commit in this state:</p></div>
 1248 <div class="listingblock">
 1249 <div class="content">
 1250 <pre><code>$ edit; git add; git commit
 1251 
 1252          HEAD (refers to commit 'f')
 1253           |
 1254           v
 1255       e---f
 1256      /
 1257 a---b---c---d  branch 'master' (refers to commit 'd')
 1258     ^
 1259     |
 1260   tag 'v2.0' (refers to commit 'b')</code></pre>
 1261 </div></div>
 1262 <div class="paragraph"><p>In fact, we can perform all the normal Git operations. But, let&#8217;s look
 1263 at what happens when we then checkout master:</p></div>
 1264 <div class="listingblock">
 1265 <div class="content">
 1266 <pre><code>$ git checkout master
 1267 
 1268                HEAD (refers to branch 'master')
 1269       e---f     |
 1270      /          v
 1271 a---b---c---d  branch 'master' (refers to commit 'd')
 1272     ^
 1273     |
 1274   tag 'v2.0' (refers to commit 'b')</code></pre>
 1275 </div></div>
 1276 <div class="paragraph"><p>It is important to realize that at this point nothing refers to commit
 1277 <em>f</em>. Eventually commit <em>f</em> (and by extension commit <em>e</em>) will be deleted
 1278 by the routine Git garbage collection process, unless we create a reference
 1279 before that happens. If we have not yet moved away from commit <em>f</em>,
 1280 any of these will create a reference to it:</p></div>
 1281 <div class="listingblock">
 1282 <div class="content">
 1283 <pre><code>$ git checkout -b foo   <b>&lt;1&gt;</b>
 1284 $ git branch foo        <b>&lt;2&gt;</b>
 1285 $ git tag foo           <b>&lt;3&gt;</b></code></pre>
 1286 </div></div>
 1287 <div class="colist arabic"><ol>
 1288 <li>
 1289 <p>
 1290 creates a new branch <em>foo</em>, which refers to commit <em>f</em>, and then
 1291 updates HEAD to refer to branch <em>foo</em>. In other words, we&#8217;ll no longer
 1292 be in detached HEAD state after this command.
 1293 </p>
 1294 </li>
 1295 <li>
 1296 <p>
 1297 similarly creates a new branch <em>foo</em>, which refers to commit <em>f</em>,
 1298 but leaves HEAD detached.
 1299 </p>
 1300 </li>
 1301 <li>
 1302 <p>
 1303 creates a new tag <em>foo</em>, which refers to commit <em>f</em>,
 1304 leaving HEAD detached.
 1305 </p>
 1306 </li>
 1307 </ol></div>
 1308 <div class="paragraph"><p>If we have moved away from commit <em>f</em>, then we must first recover its object
 1309 name (typically by using git reflog), and then we can create a reference to
 1310 it. For example, to see the last two commits to which HEAD referred, we
 1311 can use either of these commands:</p></div>
 1312 <div class="listingblock">
 1313 <div class="content">
 1314 <pre><code>$ git reflog -2 HEAD # or
 1315 $ git log -g -2 HEAD</code></pre>
 1316 </div></div>
 1317 </div>
 1318 </div>
 1319 <div class="sect1">
 1320 <h2 id="_argument_disambiguation">ARGUMENT DISAMBIGUATION</h2>
 1321 <div class="sectionbody">
 1322 <div class="paragraph"><p>When there is only one argument given and it is not <code>--</code> (e.g. "git
 1323 checkout abc"), and when the argument is both a valid <code>&lt;tree-ish&gt;</code>
 1324 (e.g. a branch "abc" exists) and a valid <code>&lt;pathspec&gt;</code> (e.g. a file
 1325 or a directory whose name is "abc" exists), Git would usually ask
 1326 you to disambiguate.  Because checking out a branch is so common an
 1327 operation, however, "git checkout abc" takes "abc" as a <code>&lt;tree-ish&gt;</code>
 1328 in such a situation.  Use <code>git checkout -- &lt;pathspec&gt;</code> if you want
 1329 to checkout these paths out of the index.</p></div>
 1330 </div>
 1331 </div>
 1332 <div class="sect1">
 1333 <h2 id="_examples">EXAMPLES</h2>
 1334 <div class="sectionbody">
 1335 <div class="olist arabic"><ol class="arabic">
 1336 <li>
 1337 <p>
 1338 The following sequence checks out the <code>master</code> branch, reverts
 1339 the <code>Makefile</code> to two revisions back, deletes hello.c by
 1340 mistake, and gets it back from the index.
 1341 </p>
 1342 <div class="listingblock">
 1343 <div class="content">
 1344 <pre><code>$ git checkout master             <b>&lt;1&gt;</b>
 1345 $ git checkout master~2 Makefile  <b>&lt;2&gt;</b>
 1346 $ rm -f hello.c
 1347 $ git checkout hello.c            <b>&lt;3&gt;</b></code></pre>
 1348 </div></div>
 1349 <div class="colist arabic"><ol>
 1350 <li>
 1351 <p>
 1352 switch branch
 1353 </p>
 1354 </li>
 1355 <li>
 1356 <p>
 1357 take a file out of another commit
 1358 </p>
 1359 </li>
 1360 <li>
 1361 <p>
 1362 restore hello.c from the index
 1363 </p>
 1364 <div class="paragraph"><p>If you want to check out <em>all</em> C source files out of the index,
 1365 you can say</p></div>
 1366 <div class="listingblock">
 1367 <div class="content">
 1368 <pre><code>$ git checkout -- '*.c'</code></pre>
 1369 </div></div>
 1370 <div class="paragraph"><p>Note the quotes around <code>*.c</code>.  The file <code>hello.c</code> will also be
 1371 checked out, even though it is no longer in the working tree,
 1372 because the file globbing is used to match entries in the index
 1373 (not in the working tree by the shell).</p></div>
 1374 <div class="paragraph"><p>If you have an unfortunate branch that is named <code>hello.c</code>, this
 1375 step would be confused as an instruction to switch to that branch.
 1376 You should instead write:</p></div>
 1377 <div class="listingblock">
 1378 <div class="content">
 1379 <pre><code>$ git checkout -- hello.c</code></pre>
 1380 </div></div>
 1381 </li>
 1382 </ol></div>
 1383 </li>
 1384 <li>
 1385 <p>
 1386 After working in the wrong branch, switching to the correct
 1387 branch would be done using:
 1388 </p>
 1389 <div class="listingblock">
 1390 <div class="content">
 1391 <pre><code>$ git checkout mytopic</code></pre>
 1392 </div></div>
 1393 <div class="paragraph"><p>However, your "wrong" branch and correct "mytopic" branch may
 1394 differ in files that you have modified locally, in which case
 1395 the above checkout would fail like this:</p></div>
 1396 <div class="listingblock">
 1397 <div class="content">
 1398 <pre><code>$ git checkout mytopic
 1399 error: You have local changes to 'frotz'; not switching branches.</code></pre>
 1400 </div></div>
 1401 <div class="paragraph"><p>You can give the <code>-m</code> flag to the command, which would try a
 1402 three-way merge:</p></div>
 1403 <div class="listingblock">
 1404 <div class="content">
 1405 <pre><code>$ git checkout -m mytopic
 1406 Auto-merging frotz</code></pre>
 1407 </div></div>
 1408 <div class="paragraph"><p>After this three-way merge, the local modifications are <em>not</em>
 1409 registered in your index file, so <code>git diff</code> would show you what
 1410 changes you made since the tip of the new branch.</p></div>
 1411 </li>
 1412 <li>
 1413 <p>
 1414 When a merge conflict happens during switching branches with
 1415 the <code>-m</code> option, you would see something like this:
 1416 </p>
 1417 <div class="listingblock">
 1418 <div class="content">
 1419 <pre><code>$ git checkout -m mytopic
 1420 Auto-merging frotz
 1421 ERROR: Merge conflict in frotz
 1422 fatal: merge program failed</code></pre>
 1423 </div></div>
 1424 <div class="paragraph"><p>At this point, <code>git diff</code> shows the changes cleanly merged as in
 1425 the previous example, as well as the changes in the conflicted
 1426 files.  Edit and resolve the conflict and mark it resolved with
 1427 <code>git add</code> as usual:</p></div>
 1428 <div class="listingblock">
 1429 <div class="content">
 1430 <pre><code>$ edit frotz
 1431 $ git add frotz</code></pre>
 1432 </div></div>
 1433 </li>
 1434 </ol></div>
 1435 </div>
 1436 </div>
 1437 <div class="sect1">
 1438 <h2 id="_git">GIT</h2>
 1439 <div class="sectionbody">
 1440 <div class="paragraph"><p>Part of the <a href="git.html">git(1)</a> suite</p></div>
 1441 </div>
 1442 </div>
 1443 </div>
 1444 <div id="footnotes"><hr /></div>
 1445 <div id="footer">
 1446 <div id="footer-text">
 1447 Last updated
 1448  2018-12-15 13:06:11 JST
 1449 </div>
 1450 </div>
 1451 </body>
 1452 </html>