Autogenerated HTML docs for v2.45.0-31-gd4cc1
[git-htmldocs.git] / git-read-tree.html
blob1968d7e8662adebbe2f8b6da9e212e2b390ed1e4
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 10.2.0" />
8 <title>git-read-tree(1)</title>
9 <style type="text/css">
10 /* Shared CSS for AsciiDoc xhtml11 and html5 backends */
12 /* Default font. */
13 body {
14 font-family: Georgia,serif;
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;
27 body {
28 margin: 1em 5% 1em 5%;
31 a {
32 color: blue;
33 text-decoration: underline;
35 a:visited {
36 color: fuchsia;
39 em {
40 font-style: italic;
41 color: navy;
44 strong {
45 font-weight: bold;
46 color: #083194;
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;
56 h1, h2, h3 {
57 border-bottom: 2px solid silver;
59 h2 {
60 padding-top: 0.5em;
62 h3 {
63 float: left;
65 h3 + * {
66 clear: left;
68 h5 {
69 font-size: 1.0em;
72 div.sectionbody {
73 margin-left: 0;
76 hr {
77 border: 1px solid silver;
80 p {
81 margin-top: 0.5em;
82 margin-bottom: 0.5em;
85 ul, ol, li > p {
86 margin-top: 0;
88 ul > li { color: #aaa; }
89 ul > li > * { color: black; }
91 .monospaced, code, pre {
92 font-family: "Courier New", Courier, monospace;
93 font-size: inherit;
94 color: navy;
95 padding: 0;
96 margin: 0;
98 pre {
99 white-space: pre-wrap;
102 #author {
103 color: #527bbd;
104 font-weight: bold;
105 font-size: 1.1em;
107 #email {
109 #revnumber, #revdate, #revremark {
112 #footer {
113 font-size: small;
114 border-top: 2px solid silver;
115 padding-top: 0.5em;
116 margin-top: 4.0em;
118 #footer-text {
119 float: left;
120 padding-bottom: 0.5em;
122 #footer-badges {
123 float: right;
124 padding-bottom: 0.5em;
127 #preamble {
128 margin-top: 1.5em;
129 margin-bottom: 1.5em;
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;
137 div.admonitionblock {
138 margin-top: 2.0em;
139 margin-bottom: 2.0em;
140 margin-right: 10%;
141 color: #606060;
144 div.content { /* Block element content. */
145 padding: 0;
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;
156 div.title + * {
157 margin-top: 0;
160 td div.title:first-child {
161 margin-top: 0.0em;
163 div.content div.title:first-child {
164 margin-top: 0.0em;
166 div.content + div.title {
167 margin-top: 0.0em;
170 div.sidebarblock > div.content {
171 background: #ffffee;
172 border: 1px solid #dddddd;
173 border-left: 4px solid #f0f0f0;
174 padding: 0.5em;
177 div.listingblock > div.content {
178 border: 1px solid #dddddd;
179 border-left: 5px solid #f0f0f0;
180 background: #f8f8f8;
181 padding: 0.5em;
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;
192 div.quoteblock > div.attribution {
193 padding-top: 0.5em;
194 text-align: right;
197 div.verseblock > pre.content {
198 font-family: inherit;
199 font-size: inherit;
201 div.verseblock > div.attribution {
202 padding-top: 0.75em;
203 text-align: left;
205 /* DEPRECATED: Pre version 8.2.7 verse style literal block. */
206 div.verseblock + div.attribution {
207 text-align: left;
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;
218 div.admonitionblock td.content {
219 padding-left: 0.5em;
220 border-left: 3px solid #dddddd;
223 div.exampleblock > div.content {
224 border-left: 3px solid #dddddd;
225 padding-left: 0.5em;
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; }
232 dl {
233 margin-top: 0.8em;
234 margin-bottom: 0.8em;
236 dt {
237 margin-top: 0.5em;
238 margin-bottom: 0;
239 font-style: normal;
240 color: navy;
242 dd > *:first-child {
243 margin-top: 0.1em;
246 ul, ol {
247 list-style-position: outside;
249 ol.arabic {
250 list-style-type: decimal;
252 ol.loweralpha {
253 list-style-type: lower-alpha;
255 ol.upperalpha {
256 list-style-type: upper-alpha;
258 ol.lowerroman {
259 list-style-type: lower-roman;
261 ol.upperroman {
262 list-style-type: upper-roman;
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;
272 tfoot {
273 font-weight: bold;
275 td > div.verse {
276 white-space: pre;
279 div.hdlist {
280 margin-top: 0.8em;
281 margin-bottom: 0.8em;
283 div.hdlist tr {
284 padding-bottom: 15px;
286 dt.hdlist1.strong, td.hdlist1.strong {
287 font-weight: bold;
289 td.hdlist1 {
290 vertical-align: top;
291 font-style: normal;
292 padding-right: 0.8em;
293 color: navy;
295 td.hdlist2 {
296 vertical-align: top;
298 div.hdlist.compact tr {
299 margin: 0;
300 padding-bottom: 0;
303 .comment {
304 background: yellow;
307 .footnote, .footnoteref {
308 font-size: 0.8em;
311 span.footnote, span.footnoteref {
312 vertical-align: super;
315 #footnotes {
316 margin: 20px 0 20px 0;
317 padding: 7px 0 0 0;
320 #footnotes div.footnote {
321 margin: 0 0 5px 0;
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;
334 div.colist td {
335 padding-right: 0.5em;
336 padding-bottom: 0.3em;
337 vertical-align: top;
339 div.colist td img {
340 margin-top: 0.3em;
343 @media print {
344 #footer-badges { display: none; }
347 #toc {
348 margin-bottom: 2.5em;
351 #toctitle {
352 color: #527bbd;
353 font-size: 1.1em;
354 font-weight: bold;
355 margin-top: 1.0em;
356 margin-bottom: 0.1em;
359 div.toclevel0, div.toclevel1, div.toclevel2, div.toclevel3, div.toclevel4 {
360 margin-top: 0;
361 margin-bottom: 0;
363 div.toclevel2 {
364 margin-left: 2em;
365 font-size: 0.9em;
367 div.toclevel3 {
368 margin-left: 4em;
369 font-size: 0.9em;
371 div.toclevel4 {
372 margin-left: 6em;
373 font-size: 0.9em;
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; }
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; }
410 span.big { font-size: 2em; }
411 span.small { font-size: 0.6em; }
413 span.underline { text-decoration: underline; }
414 span.overline { text-decoration: overline; }
415 span.line-through { text-decoration: line-through; }
417 div.unbreakable { page-break-inside: avoid; }
421 * xhtml11 specific
423 * */
425 div.tableblock {
426 margin-top: 1.0em;
427 margin-bottom: 1.5em;
429 div.tableblock > table {
430 border: 3px solid #527bbd;
432 thead, p.table.header {
433 font-weight: bold;
434 color: #527bbd;
436 p.table {
437 margin-top: 0;
439 /* Because the table frame attribute is overridden by CSS in most browsers. */
440 div.tableblock > table[frame="void"] {
441 border-style: none;
443 div.tableblock > table[frame="hsides"] {
444 border-left-style: none;
445 border-right-style: none;
447 div.tableblock > table[frame="vsides"] {
448 border-top-style: none;
449 border-bottom-style: none;
454 * html5 specific
456 * */
458 table.tableblock {
459 margin-top: 1.0em;
460 margin-bottom: 1.5em;
462 thead, p.tableblock.header {
463 font-weight: bold;
464 color: #527bbd;
466 p.tableblock {
467 margin-top: 0;
469 table.tableblock {
470 border-width: 3px;
471 border-spacing: 0px;
472 border-style: solid;
473 border-color: #527bbd;
474 border-collapse: collapse;
476 th.tableblock, td.tableblock {
477 border-width: 1px;
478 padding: 4px;
479 border-style: solid;
480 border-color: #527bbd;
483 table.tableblock.frame-topbot {
484 border-left-style: hidden;
485 border-right-style: hidden;
487 table.tableblock.frame-sides {
488 border-top-style: hidden;
489 border-bottom-style: hidden;
491 table.tableblock.frame-none {
492 border-style: hidden;
495 th.tableblock.halign-left, td.tableblock.halign-left {
496 text-align: left;
498 th.tableblock.halign-center, td.tableblock.halign-center {
499 text-align: center;
501 th.tableblock.halign-right, td.tableblock.halign-right {
502 text-align: right;
505 th.tableblock.valign-top, td.tableblock.valign-top {
506 vertical-align: top;
508 th.tableblock.valign-middle, td.tableblock.valign-middle {
509 vertical-align: middle;
511 th.tableblock.valign-bottom, td.tableblock.valign-bottom {
512 vertical-align: bottom;
517 * manpage specific
519 * */
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;
527 body.manpage h2 {
528 border-style: none;
530 body.manpage div.sectionbody {
531 margin-left: 3em;
534 @media print {
535 body.manpage div#toc { display: none; }
539 </style>
540 <script type="text/javascript">
541 /*<![CDATA[*/
542 var asciidoc = { // Namespace.
544 /////////////////////////////////////////////////////////////////////
545 // Table Of Contents generator
546 /////////////////////////////////////////////////////////////////////
548 /* Author: Mihai Bazon, September 2002
549 * http://students.infoiasi.ro/~mishoo
551 * Table Of Content generator
552 * Version: 0.4
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.
558 /* modified by Troy D. Hanson, September 2006. License: GPL */
559 /* modified by Stuart Rackham, 2006, 2009. License: GPL */
561 // toclevels = 1..4.
562 toc: function (toclevels) {
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);
572 return text;
575 function TocEntry(el, text, toclevel) {
576 this.element = el;
577 this.text = text;
578 this.toclevel = toclevel;
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);
594 iterate(i);
598 iterate(el);
599 return result;
602 var toc = document.getElementById("toc");
603 if (!toc) {
604 return;
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);
617 for (i = 0; i < tocEntriesToRemove.length; i++) {
618 toc.removeChild(tocEntriesToRemove[i]);
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);
635 if (entries.length == 0)
636 toc.parentNode.removeChild(toc);
640 /////////////////////////////////////////////////////////////////////
641 // Footnotes generator
642 /////////////////////////////////////////////////////////////////////
644 /* Based on footnote generation code from:
645 * http://www.brandspankingnew.net/archive/2005/07/format_footnote.html
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;
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);
661 for (i = 0; i < entriesToRemove.length; i++) {
662 noteholder.removeChild(entriesToRemove[i]);
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);
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;
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>]";
708 install: function(toclevels) {
709 var timerId;
711 function reinstall() {
712 asciidoc.footnotes();
713 if (toclevels) {
714 asciidoc.toc(toclevels);
718 function reinstallAndRemoveTimer() {
719 clearInterval(timerId);
720 reinstall();
723 timerId = setInterval(reinstall, 500);
724 if (document.addEventListener)
725 document.addEventListener("DOMContentLoaded", reinstallAndRemoveTimer, false);
726 else
727 window.onload = reinstallAndRemoveTimer;
731 asciidoc.install();
732 /*]]>*/
733 </script>
734 </head>
735 <body class="manpage">
736 <div id="header">
737 <h1>
738 git-read-tree(1) Manual Page
739 </h1>
740 <h2>NAME</h2>
741 <div class="sectionbody">
742 <p>git-read-tree -
743 Reads tree information into the index
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 read-tree</em> [(-m [--trivial] [--aggressive] | --reset | --prefix=&lt;prefix&gt;)
753 [-u | -i]] [--index-output=&lt;file&gt;] [--no-sparse-checkout]
754 (--empty | &lt;tree-ish1&gt; [&lt;tree-ish2&gt; [&lt;tree-ish3&gt;]])</pre>
755 <div class="attribution">
756 </div></div>
757 </div>
758 </div>
759 <div class="sect1">
760 <h2 id="_description">DESCRIPTION</h2>
761 <div class="sectionbody">
762 <div class="paragraph"><p>Reads the tree information given by &lt;tree-ish&gt; into the index,
763 but does not actually <strong>update</strong> any of the files it "caches". (see:
764 <a href="git-checkout-index.html">git-checkout-index(1)</a>)</p></div>
765 <div class="paragraph"><p>Optionally, it can merge a tree into the index, perform a
766 fast-forward (i.e. 2-way) merge, or a 3-way merge, with the <code>-m</code>
767 flag. When used with <code>-m</code>, the <code>-u</code> flag causes it to also update
768 the files in the work tree with the result of the merge.</p></div>
769 <div class="paragraph"><p>Only trivial merges are done by <em>git read-tree</em> itself. Only conflicting paths
770 will be in an unmerged state when <em>git read-tree</em> returns.</p></div>
771 </div>
772 </div>
773 <div class="sect1">
774 <h2 id="_options">OPTIONS</h2>
775 <div class="sectionbody">
776 <div class="dlist"><dl>
777 <dt class="hdlist1">
779 </dt>
780 <dd>
782 Perform a merge, not just a read. The command will
783 refuse to run if your index file has unmerged entries,
784 indicating that you have not finished a previous merge you
785 started.
786 </p>
787 </dd>
788 <dt class="hdlist1">
789 --reset
790 </dt>
791 <dd>
793 Same as -m, except that unmerged entries are discarded instead
794 of failing. When used with <code>-u</code>, updates leading to loss of
795 working tree changes or untracked files or directories will not
796 abort the operation.
797 </p>
798 </dd>
799 <dt class="hdlist1">
801 </dt>
802 <dd>
804 After a successful merge, update the files in the work
805 tree with the result of the merge.
806 </p>
807 </dd>
808 <dt class="hdlist1">
810 </dt>
811 <dd>
813 Usually a merge requires the index file as well as the
814 files in the working tree to be up to date with the
815 current head commit, in order not to lose local
816 changes. This flag disables the check with the working
817 tree and is meant to be used when creating a merge of
818 trees that are not directly related to the current
819 working tree status into a temporary index file.
820 </p>
821 </dd>
822 <dt class="hdlist1">
824 </dt>
825 <dt class="hdlist1">
826 --dry-run
827 </dt>
828 <dd>
830 Check if the command would error out, without updating the index
831 or the files in the working tree for real.
832 </p>
833 </dd>
834 <dt class="hdlist1">
836 </dt>
837 <dd>
839 Show the progress of checking files out.
840 </p>
841 </dd>
842 <dt class="hdlist1">
843 --trivial
844 </dt>
845 <dd>
847 Restrict three-way merge by <em>git read-tree</em> to happen
848 only if there is no file-level merging required, instead
849 of resolving merge for trivial cases and leaving
850 conflicting files unresolved in the index.
851 </p>
852 </dd>
853 <dt class="hdlist1">
854 --aggressive
855 </dt>
856 <dd>
858 Usually a three-way merge by <em>git read-tree</em> resolves
859 the merge for really trivial cases and leaves other
860 cases unresolved in the index, so that porcelains can
861 implement different merge policies. This flag makes the
862 command resolve a few more cases internally:
863 </p>
864 <div class="ulist"><ul>
865 <li>
867 when one side removes a path and the other side leaves the path
868 unmodified. The resolution is to remove that path.
869 </p>
870 </li>
871 <li>
873 when both sides remove a path. The resolution is to remove that path.
874 </p>
875 </li>
876 <li>
878 when both sides add a path identically. The resolution
879 is to add that path.
880 </p>
881 </li>
882 </ul></div>
883 </dd>
884 <dt class="hdlist1">
885 --prefix=&lt;prefix&gt;
886 </dt>
887 <dd>
889 Keep the current index contents, and read the contents
890 of the named tree-ish under the directory at <code>&lt;prefix&gt;</code>.
891 The command will refuse to overwrite entries that already
892 existed in the original index file.
893 </p>
894 </dd>
895 <dt class="hdlist1">
896 --index-output=&lt;file&gt;
897 </dt>
898 <dd>
900 Instead of writing the results out to <code>$GIT_INDEX_FILE</code>,
901 write the resulting index in the named file. While the
902 command is operating, the original index file is locked
903 with the same mechanism as usual. The file must allow
904 to be rename(2)ed into from a temporary file that is
905 created next to the usual index file; typically this
906 means it needs to be on the same filesystem as the index
907 file itself, and you need write permission to the
908 directories the index file and index output file are
909 located in.
910 </p>
911 </dd>
912 <dt class="hdlist1">
913 --[no-]recurse-submodules
914 </dt>
915 <dd>
917 Using --recurse-submodules will update the content of all active
918 submodules according to the commit recorded in the superproject by
919 calling read-tree recursively, also setting the submodules' HEAD to be
920 detached at that commit.
921 </p>
922 </dd>
923 <dt class="hdlist1">
924 --no-sparse-checkout
925 </dt>
926 <dd>
928 Disable sparse checkout support even if <code>core.sparseCheckout</code>
929 is true.
930 </p>
931 </dd>
932 <dt class="hdlist1">
933 --empty
934 </dt>
935 <dd>
937 Instead of reading tree object(s) into the index, just empty
939 </p>
940 </dd>
941 <dt class="hdlist1">
943 </dt>
944 <dt class="hdlist1">
945 --quiet
946 </dt>
947 <dd>
949 Quiet, suppress feedback messages.
950 </p>
951 </dd>
952 <dt class="hdlist1">
953 &lt;tree-ish#&gt;
954 </dt>
955 <dd>
957 The id of the tree object(s) to be read/merged.
958 </p>
959 </dd>
960 </dl></div>
961 </div>
962 </div>
963 <div class="sect1">
964 <h2 id="_merging">MERGING</h2>
965 <div class="sectionbody">
966 <div class="paragraph"><p>If <code>-m</code> is specified, <em>git read-tree</em> can perform 3 kinds of
967 merge, a single tree merge if only 1 tree is given, a
968 fast-forward merge with 2 trees, or a 3-way merge if 3 or more trees are
969 provided.</p></div>
970 <div class="sect2">
971 <h3 id="_single_tree_merge">Single Tree Merge</h3>
972 <div class="paragraph"><p>If only 1 tree is specified, <em>git read-tree</em> operates as if the user did not
973 specify <code>-m</code>, except that if the original index has an entry for a
974 given pathname, and the contents of the path match with the tree
975 being read, the stat info from the index is used. (In other words, the
976 index&#8217;s stat()s take precedence over the merged tree&#8217;s).</p></div>
977 <div class="paragraph"><p>That means that if you do a <code>git read-tree -m &lt;newtree&gt;</code> followed by a
978 <code>git checkout-index -f -u -a</code>, the <em>git checkout-index</em> only checks out
979 the stuff that really changed.</p></div>
980 <div class="paragraph"><p>This is used to avoid unnecessary false hits when <em>git diff-files</em> is
981 run after <em>git read-tree</em>.</p></div>
982 </div>
983 <div class="sect2">
984 <h3 id="_two_tree_merge">Two Tree Merge</h3>
985 <div class="paragraph"><p>Typically, this is invoked as <code>git read-tree -m $H $M</code>, where $H
986 is the head commit of the current repository, and $M is the head
987 of a foreign tree, which is simply ahead of $H (i.e. we are in a
988 fast-forward situation).</p></div>
989 <div class="paragraph"><p>When two trees are specified, the user is telling <em>git read-tree</em>
990 the following:</p></div>
991 <div class="olist arabic"><ol class="arabic">
992 <li>
994 The current index and work tree is derived from $H, but
995 the user may have local changes in them since $H.
996 </p>
997 </li>
998 <li>
1000 The user wants to fast-forward to $M.
1001 </p>
1002 </li>
1003 </ol></div>
1004 <div class="paragraph"><p>In this case, the <code>git read-tree -m $H $M</code> command makes sure
1005 that no local change is lost as the result of this "merge".
1006 Here are the "carry forward" rules, where "I" denotes the index,
1007 "clean" means that index and work tree coincide, and "exists"/"nothing"
1008 refer to the presence of a path in the specified commit:</p></div>
1009 <div class="literalblock">
1010 <div class="content">
1011 <pre><code> I H M Result
1012 -------------------------------------------------------
1013 0 nothing nothing nothing (does not happen)
1014 1 nothing nothing exists use M
1015 2 nothing exists nothing remove path from index
1016 3 nothing exists exists, use M if "initial checkout",
1017 H == M keep index otherwise
1018 exists, fail
1019 H != M
1021 clean I==H I==M
1022 ------------------
1023 4 yes N/A N/A nothing nothing keep index
1024 5 no N/A N/A nothing nothing keep index
1026 6 yes N/A yes nothing exists keep index
1027 7 no N/A yes nothing exists keep index
1028 8 yes N/A no nothing exists fail
1029 9 no N/A no nothing exists fail
1031 10 yes yes N/A exists nothing remove path from index
1032 11 no yes N/A exists nothing fail
1033 12 yes no N/A exists nothing fail
1034 13 no no N/A exists nothing fail
1036 clean (H==M)
1037 ------
1038 14 yes exists exists keep index
1039 15 no exists exists keep index
1041 clean I==H I==M (H!=M)
1042 ------------------
1043 16 yes no no exists exists fail
1044 17 no no no exists exists fail
1045 18 yes no yes exists exists keep index
1046 19 no no yes exists exists keep index
1047 20 yes yes no exists exists use M
1048 21 no yes no exists exists fail</code></pre>
1049 </div></div>
1050 <div class="paragraph"><p>In all "keep index" cases, the index entry stays as in the
1051 original index file. If the entry is not up to date,
1052 <em>git read-tree</em> keeps the copy in the work tree intact when
1053 operating under the -u flag.</p></div>
1054 <div class="paragraph"><p>When this form of <em>git read-tree</em> returns successfully, you can
1055 see which of the "local changes" that you made were carried forward by running
1056 <code>git diff-index --cached $M</code>. Note that this does not
1057 necessarily match what <code>git diff-index --cached $H</code> would have
1058 produced before such a two tree merge. This is because of cases
1059 18 and 19&#8201;&#8212;&#8201;if you already had the changes in $M (e.g. maybe
1060 you picked it up via e-mail in a patch form), <code>git diff-index
1061 --cached $H</code> would have told you about the change before this
1062 merge, but it would not show in <code>git diff-index --cached $M</code>
1063 output after the two-tree merge.</p></div>
1064 <div class="paragraph"><p>Case 3 is slightly tricky and needs explanation. The result from this
1065 rule logically should be to remove the path if the user staged the removal
1066 of the path and then switching to a new branch. That however will prevent
1067 the initial checkout from happening, so the rule is modified to use M (new
1068 tree) only when the content of the index is empty. Otherwise the removal
1069 of the path is kept as long as $H and $M are the same.</p></div>
1070 </div>
1071 <div class="sect2">
1072 <h3 id="_3_way_merge">3-Way Merge</h3>
1073 <div class="paragraph"><p>Each "index" entry has two bits worth of "stage" state. stage 0 is the
1074 normal one, and is the only one you&#8217;d see in any kind of normal use.</p></div>
1075 <div class="paragraph"><p>However, when you do <em>git read-tree</em> with three trees, the "stage"
1076 starts out at 1.</p></div>
1077 <div class="paragraph"><p>This means that you can do</p></div>
1078 <div class="listingblock">
1079 <div class="content">
1080 <pre><code>$ git read-tree -m &lt;tree1&gt; &lt;tree2&gt; &lt;tree3&gt;</code></pre>
1081 </div></div>
1082 <div class="paragraph"><p>and you will end up with an index with all of the &lt;tree1&gt; entries in
1083 "stage1", all of the &lt;tree2&gt; entries in "stage2" and all of the
1084 &lt;tree3&gt; entries in "stage3". When performing a merge of another
1085 branch into the current branch, we use the common ancestor tree
1086 as &lt;tree1&gt;, the current branch head as &lt;tree2&gt;, and the other
1087 branch head as &lt;tree3&gt;.</p></div>
1088 <div class="paragraph"><p>Furthermore, <em>git read-tree</em> has special-case logic that says: if you see
1089 a file that matches in all respects in the following states, it
1090 "collapses" back to "stage0":</p></div>
1091 <div class="ulist"><ul>
1092 <li>
1094 stage 2 and 3 are the same; take one or the other (it makes no
1095 difference - the same work has been done on our branch in
1096 stage 2 and their branch in stage 3)
1097 </p>
1098 </li>
1099 <li>
1101 stage 1 and stage 2 are the same and stage 3 is different; take
1102 stage 3 (our branch in stage 2 did not do anything since the
1103 ancestor in stage 1 while their branch in stage 3 worked on
1105 </p>
1106 </li>
1107 <li>
1109 stage 1 and stage 3 are the same and stage 2 is different take
1110 stage 2 (we did something while they did nothing)
1111 </p>
1112 </li>
1113 </ul></div>
1114 <div class="paragraph"><p>The <em>git write-tree</em> command refuses to write a nonsensical tree, and it
1115 will complain about unmerged entries if it sees a single entry that is not
1116 stage 0.</p></div>
1117 <div class="paragraph"><p>OK, this all sounds like a collection of totally nonsensical rules,
1118 but it&#8217;s actually exactly what you want in order to do a fast
1119 merge. The different stages represent the "result tree" (stage 0, aka
1120 "merged"), the original tree (stage 1, aka "orig"), and the two trees
1121 you are trying to merge (stage 2 and 3 respectively).</p></div>
1122 <div class="paragraph"><p>The order of stages 1, 2 and 3 (hence the order of three
1123 &lt;tree-ish&gt; command-line arguments) are significant when you
1124 start a 3-way merge with an index file that is already
1125 populated. Here is an outline of how the algorithm works:</p></div>
1126 <div class="ulist"><ul>
1127 <li>
1129 if a file exists in identical format in all three trees, it will
1130 automatically collapse to "merged" state by <em>git read-tree</em>.
1131 </p>
1132 </li>
1133 <li>
1135 a file that has <em>any</em> difference what-so-ever in the three trees
1136 will stay as separate entries in the index. It&#8217;s up to "porcelain
1137 policy" to determine how to remove the non-0 stages, and insert a
1138 merged version.
1139 </p>
1140 </li>
1141 <li>
1143 the index file saves and restores with all this information, so you
1144 can merge things incrementally, but as long as it has entries in
1145 stages 1/2/3 (i.e., "unmerged entries") you can&#8217;t write the result. So
1146 now the merge algorithm ends up being really simple:
1147 </p>
1148 <div class="ulist"><ul>
1149 <li>
1151 you walk the index in order, and ignore all entries of stage 0,
1152 since they&#8217;ve already been done.
1153 </p>
1154 </li>
1155 <li>
1157 if you find a "stage1", but no matching "stage2" or "stage3", you
1158 know it&#8217;s been removed from both trees (it only existed in the
1159 original tree), and you remove that entry.
1160 </p>
1161 </li>
1162 <li>
1164 if you find a matching "stage2" and "stage3" tree, you remove one
1165 of them, and turn the other into a "stage0" entry. Remove any
1166 matching "stage1" entry if it exists too. .. all the normal
1167 trivial rules ..
1168 </p>
1169 </li>
1170 </ul></div>
1171 </li>
1172 </ul></div>
1173 <div class="paragraph"><p>You would normally use <em>git merge-index</em> with supplied
1174 <em>git merge-one-file</em> to do this last step. The script updates
1175 the files in the working tree as it merges each path and at the
1176 end of a successful merge.</p></div>
1177 <div class="paragraph"><p>When you start a 3-way merge with an index file that is already
1178 populated, it is assumed that it represents the state of the
1179 files in your work tree, and you can even have files with
1180 changes unrecorded in the index file. It is further assumed
1181 that this state is "derived" from the stage 2 tree. The 3-way
1182 merge refuses to run if it finds an entry in the original index
1183 file that does not match stage 2.</p></div>
1184 <div class="paragraph"><p>This is done to prevent you from losing your work-in-progress
1185 changes, and mixing your random changes in an unrelated merge
1186 commit. To illustrate, suppose you start from what has been
1187 committed last to your repository:</p></div>
1188 <div class="listingblock">
1189 <div class="content">
1190 <pre><code>$ JC=`git rev-parse --verify "HEAD^0"`
1191 $ git checkout-index -f -u -a $JC</code></pre>
1192 </div></div>
1193 <div class="paragraph"><p>You do random edits, without running <em>git update-index</em>. And then
1194 you notice that the tip of your "upstream" tree has advanced
1195 since you pulled from him:</p></div>
1196 <div class="listingblock">
1197 <div class="content">
1198 <pre><code>$ git fetch git://.... linus
1199 $ LT=`git rev-parse FETCH_HEAD`</code></pre>
1200 </div></div>
1201 <div class="paragraph"><p>Your work tree is still based on your HEAD ($JC), but you have
1202 some edits since. Three-way merge makes sure that you have not
1203 added or modified index entries since $JC, and if you haven&#8217;t,
1204 then does the right thing. So with the following sequence:</p></div>
1205 <div class="listingblock">
1206 <div class="content">
1207 <pre><code>$ git read-tree -m -u `git merge-base $JC $LT` $JC $LT
1208 $ git merge-index git-merge-one-file -a
1209 $ echo "Merge with Linus" | \
1210 git commit-tree `git write-tree` -p $JC -p $LT</code></pre>
1211 </div></div>
1212 <div class="paragraph"><p>what you would commit is a pure merge between $JC and $LT without
1213 your work-in-progress changes, and your work tree would be
1214 updated to the result of the merge.</p></div>
1215 <div class="paragraph"><p>However, if you have local changes in the working tree that
1216 would be overwritten by this merge, <em>git read-tree</em> will refuse
1217 to run to prevent your changes from being lost.</p></div>
1218 <div class="paragraph"><p>In other words, there is no need to worry about what exists only
1219 in the working tree. When you have local changes in a part of
1220 the project that is not involved in the merge, your changes do
1221 not interfere with the merge, and are kept intact. When they
1222 <strong>do</strong> interfere, the merge does not even start (<em>git read-tree</em>
1223 complains loudly and fails without modifying anything). In such
1224 a case, you can simply continue doing what you were in the
1225 middle of doing, and when your working tree is ready (i.e. you
1226 have finished your work-in-progress), attempt the merge again.</p></div>
1227 </div>
1228 </div>
1229 </div>
1230 <div class="sect1">
1231 <h2 id="_sparse_checkout">SPARSE CHECKOUT</h2>
1232 <div class="sectionbody">
1233 <div class="paragraph"><p>Note: The skip-worktree capabilities in <a href="git-update-index.html">git-update-index(1)</a>
1234 and <code>read-tree</code> predated the introduction of
1235 <a href="git-sparse-checkout.html">git-sparse-checkout(1)</a>. Users are encouraged to use the
1236 <code>sparse-checkout</code> command in preference to these plumbing commands for
1237 sparse-checkout/skip-worktree related needs. However, the information
1238 below might be useful to users trying to understand the pattern style
1239 used in non-cone mode of the <code>sparse-checkout</code> command.</p></div>
1240 <div class="paragraph"><p>"Sparse checkout" allows populating the working directory sparsely.
1241 It uses the skip-worktree bit (see <a href="git-update-index.html">git-update-index(1)</a>) to
1242 tell Git whether a file in the working directory is worth looking at.</p></div>
1243 <div class="paragraph"><p><em>git read-tree</em> and other merge-based commands (<em>git merge</em>, <em>git
1244 checkout</em>&#8230;) can help maintaining the skip-worktree bitmap and working
1245 directory update. <code>$GIT_DIR/info/sparse-checkout</code> is used to
1246 define the skip-worktree reference bitmap. When <em>git read-tree</em> needs
1247 to update the working directory, it resets the skip-worktree bit in the index
1248 based on this file, which uses the same syntax as .gitignore files.
1249 If an entry matches a pattern in this file, or the entry corresponds to
1250 a file present in the working tree, then skip-worktree will not be
1251 set on that entry. Otherwise, skip-worktree will be set.</p></div>
1252 <div class="paragraph"><p>Then it compares the new skip-worktree value with the previous one. If
1253 skip-worktree turns from set to unset, it will add the corresponding
1254 file back. If it turns from unset to set, that file will be removed.</p></div>
1255 <div class="paragraph"><p>While <code>$GIT_DIR/info/sparse-checkout</code> is usually used to specify what
1256 files are in, you can also specify what files are <em>not</em> in, using
1257 negate patterns. For example, to remove the file <code>unwanted</code>:</p></div>
1258 <div class="listingblock">
1259 <div class="content">
1260 <pre><code>/*
1261 !unwanted</code></pre>
1262 </div></div>
1263 <div class="paragraph"><p>Another tricky thing is fully repopulating the working directory when you
1264 no longer want sparse checkout. You cannot just disable "sparse
1265 checkout" because skip-worktree bits are still in the index and your working
1266 directory is still sparsely populated. You should re-populate the working
1267 directory with the <code>$GIT_DIR/info/sparse-checkout</code> file content as
1268 follows:</p></div>
1269 <div class="listingblock">
1270 <div class="content">
1271 <pre><code>/*</code></pre>
1272 </div></div>
1273 <div class="paragraph"><p>Then you can disable sparse checkout. Sparse checkout support in <em>git
1274 read-tree</em> and similar commands is disabled by default. You need to
1275 turn <code>core.sparseCheckout</code> on in order to have sparse checkout
1276 support.</p></div>
1277 </div>
1278 </div>
1279 <div class="sect1">
1280 <h2 id="_see_also">SEE ALSO</h2>
1281 <div class="sectionbody">
1282 <div class="paragraph"><p><a href="git-write-tree.html">git-write-tree(1)</a>, <a href="git-ls-files.html">git-ls-files(1)</a>,
1283 <a href="gitignore.html">gitignore(5)</a>, <a href="git-sparse-checkout.html">git-sparse-checkout(1)</a></p></div>
1284 </div>
1285 </div>
1286 <div class="sect1">
1287 <h2 id="_git">GIT</h2>
1288 <div class="sectionbody">
1289 <div class="paragraph"><p>Part of the <a href="git.html">git(1)</a> suite</p></div>
1290 </div>
1291 </div>
1292 </div>
1293 <div id="footnotes"><hr /></div>
1294 <div id="footer">
1295 <div id="footer-text">
1296 Last updated
1297 2023-10-23 14:43:46 PDT
1298 </div>
1299 </div>
1300 </body>
1301 </html>