Autogenerated HTML docs for v2.43.0-440-gb50a60
[git-htmldocs.git] / git-worktree.html
blobd5412bb7ffa2a5c79cc8e1de67aae8967987b54b
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-worktree(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-worktree(1) Manual Page
739 </h1>
740 <h2>NAME</h2>
741 <div class="sectionbody">
742 <p>git-worktree -
743 Manage multiple working trees
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 worktree add</em> [-f] [--detach] [--checkout] [--lock [--reason &lt;string&gt;]]
753 [--orphan] [(-b | -B) &lt;new-branch&gt;] &lt;path&gt; [&lt;commit-ish&gt;]
754 <em>git worktree list</em> [-v | --porcelain [-z]]
755 <em>git worktree lock</em> [--reason &lt;string&gt;] &lt;worktree&gt;
756 <em>git worktree move</em> &lt;worktree&gt; &lt;new-path&gt;
757 <em>git worktree prune</em> [-n] [-v] [--expire &lt;expire&gt;]
758 <em>git worktree remove</em> [-f] &lt;worktree&gt;
759 <em>git worktree repair</em> [&lt;path&gt;&#8230;]
760 <em>git worktree unlock</em> &lt;worktree&gt;</pre>
761 <div class="attribution">
762 </div></div>
763 </div>
764 </div>
765 <div class="sect1">
766 <h2 id="_description">DESCRIPTION</h2>
767 <div class="sectionbody">
768 <div class="paragraph"><p>Manage multiple working trees attached to the same repository.</p></div>
769 <div class="paragraph"><p>A git repository can support multiple working trees, allowing you to check
770 out more than one branch at a time. With <code>git worktree add</code> a new working
771 tree is associated with the repository, along with additional metadata
772 that differentiates that working tree from others in the same repository.
773 The working tree, along with this metadata, is called a "worktree".</p></div>
774 <div class="paragraph"><p>This new worktree is called a "linked worktree" as opposed to the "main
775 worktree" prepared by <a href="git-init.html">git-init(1)</a> or <a href="git-clone.html">git-clone(1)</a>.
776 A repository has one main worktree (if it&#8217;s not a bare repository) and
777 zero or more linked worktrees. When you are done with a linked worktree,
778 remove it with <code>git worktree remove</code>.</p></div>
779 <div class="paragraph"><p>In its simplest form, <code>git worktree add &lt;path&gt;</code> automatically creates a
780 new branch whose name is the final component of <code>&lt;path&gt;</code>, which is
781 convenient if you plan to work on a new topic. For instance, <code>git
782 worktree add ../hotfix</code> creates new branch <code>hotfix</code> and checks it out at
783 path <code>../hotfix</code>. To instead work on an existing branch in a new worktree,
784 use <code>git worktree add &lt;path&gt; &lt;branch&gt;</code>. On the other hand, if you just
785 plan to make some experimental changes or do testing without disturbing
786 existing development, it is often convenient to create a <em>throwaway</em>
787 worktree not associated with any branch. For instance,
788 <code>git worktree add -d &lt;path&gt;</code> creates a new worktree with a detached <code>HEAD</code>
789 at the same commit as the current branch.</p></div>
790 <div class="paragraph"><p>If a working tree is deleted without using <code>git worktree remove</code>, then
791 its associated administrative files, which reside in the repository
792 (see "DETAILS" below), will eventually be removed automatically (see
793 <code>gc.worktreePruneExpire</code> in <a href="git-config.html">git-config(1)</a>), or you can run
794 <code>git worktree prune</code> in the main or any linked worktree to clean up any
795 stale administrative files.</p></div>
796 <div class="paragraph"><p>If the working tree for a linked worktree is stored on a portable device
797 or network share which is not always mounted, you can prevent its
798 administrative files from being pruned by issuing the <code>git worktree lock</code>
799 command, optionally specifying <code>--reason</code> to explain why the worktree is
800 locked.</p></div>
801 </div>
802 </div>
803 <div class="sect1">
804 <h2 id="_commands">COMMANDS</h2>
805 <div class="sectionbody">
806 <div class="dlist"><dl>
807 <dt class="hdlist1">
808 add &lt;path&gt; [&lt;commit-ish&gt;]
809 </dt>
810 <dd>
812 Create a worktree at <code>&lt;path&gt;</code> and checkout <code>&lt;commit-ish&gt;</code> into it. The new worktree
813 is linked to the current repository, sharing everything except per-worktree
814 files such as <code>HEAD</code>, <code>index</code>, etc. As a convenience, <code>&lt;commit-ish&gt;</code> may
815 be a bare "<code>-</code>", which is synonymous with <code>@{-1}</code>.
816 </p>
817 <div class="paragraph"><p>If <code>&lt;commit-ish&gt;</code> is a branch name (call it <code>&lt;branch&gt;</code>) and is not found,
818 and neither <code>-b</code> nor <code>-B</code> nor <code>--detach</code> are used, but there does
819 exist a tracking branch in exactly one remote (call it <code>&lt;remote&gt;</code>)
820 with a matching name, treat as equivalent to:</p></div>
821 <div class="listingblock">
822 <div class="content">
823 <pre><code>$ git worktree add --track -b &lt;branch&gt; &lt;path&gt; &lt;remote&gt;/&lt;branch&gt;</code></pre>
824 </div></div>
825 <div class="paragraph"><p>If the branch exists in multiple remotes and one of them is named by
826 the <code>checkout.defaultRemote</code> configuration variable, we&#8217;ll use that
827 one for the purposes of disambiguation, even if the <code>&lt;branch&gt;</code> isn&#8217;t
828 unique across all remotes. Set it to
829 e.g. <code>checkout.defaultRemote=origin</code> to always checkout remote
830 branches from there if <code>&lt;branch&gt;</code> is ambiguous but exists on the
831 <code>origin</code> remote. See also <code>checkout.defaultRemote</code> in
832 <a href="git-config.html">git-config(1)</a>.</p></div>
833 <div class="paragraph"><p>If <code>&lt;commit-ish&gt;</code> is omitted and neither <code>-b</code> nor <code>-B</code> nor <code>--detach</code> used,
834 then, as a convenience, the new worktree is associated with a branch (call
835 it <code>&lt;branch&gt;</code>) named after <code>$(basename &lt;path&gt;)</code>. If <code>&lt;branch&gt;</code> doesn&#8217;t
836 exist, a new branch based on <code>HEAD</code> is automatically created as if
837 <code>-b &lt;branch&gt;</code> was given. If <code>&lt;branch&gt;</code> does exist, it will be checked out
838 in the new worktree, if it&#8217;s not checked out anywhere else, otherwise the
839 command will refuse to create the worktree (unless <code>--force</code> is used).</p></div>
840 <div class="paragraph"><p>If <code>&lt;commit-ish&gt;</code> is omitted, neither <code>--detach</code>, or <code>--orphan</code> is
841 used, and there are no valid local branches (or remote branches if
842 <code>--guess-remote</code> is specified) then, as a convenience, the new worktree is
843 associated with a new unborn branch named <code>&lt;branch&gt;</code> (after
844 <code>$(basename &lt;path&gt;)</code> if neither <code>-b</code> or <code>-B</code> is used) as if <code>--orphan</code> was
845 passed to the command. In the event the repository has a remote and
846 <code>--guess-remote</code> is used, but no remote or local branches exist, then the
847 command fails with a warning reminding the user to fetch from their remote
848 first (or override by using <code>-f/--force</code>).</p></div>
849 </dd>
850 <dt class="hdlist1">
851 list
852 </dt>
853 <dd>
855 List details of each worktree. The main worktree is listed first,
856 followed by each of the linked worktrees. The output details include
857 whether the worktree is bare, the revision currently checked out, the
858 branch currently checked out (or "detached HEAD" if none), "locked" if
859 the worktree is locked, "prunable" if the worktree can be pruned by the
860 <code>prune</code> command.
861 </p>
862 </dd>
863 <dt class="hdlist1">
864 lock
865 </dt>
866 <dd>
868 If a worktree is on a portable device or network share which is not always
869 mounted, lock it to prevent its administrative files from being pruned
870 automatically. This also prevents it from being moved or deleted.
871 Optionally, specify a reason for the lock with <code>--reason</code>.
872 </p>
873 </dd>
874 <dt class="hdlist1">
875 move
876 </dt>
877 <dd>
879 Move a worktree to a new location. Note that the main worktree or linked
880 worktrees containing submodules cannot be moved with this command. (The
881 <code>git worktree repair</code> command, however, can reestablish the connection
882 with linked worktrees if you move the main worktree manually.)
883 </p>
884 </dd>
885 <dt class="hdlist1">
886 prune
887 </dt>
888 <dd>
890 Prune worktree information in <code>$GIT_DIR/worktrees</code>.
891 </p>
892 </dd>
893 <dt class="hdlist1">
894 remove
895 </dt>
896 <dd>
898 Remove a worktree. Only clean worktrees (no untracked files and no
899 modification in tracked files) can be removed. Unclean worktrees or ones
900 with submodules can be removed with <code>--force</code>. The main worktree cannot be
901 removed.
902 </p>
903 </dd>
904 <dt class="hdlist1">
905 repair [&lt;path&gt;&#8230;]
906 </dt>
907 <dd>
909 Repair worktree administrative files, if possible, if they have become
910 corrupted or outdated due to external factors.
911 </p>
912 <div class="paragraph"><p>For instance, if the main worktree (or bare repository) is moved, linked
913 worktrees will be unable to locate it. Running <code>repair</code> in the main
914 worktree will reestablish the connection from linked worktrees back to the
915 main worktree.</p></div>
916 <div class="paragraph"><p>Similarly, if the working tree for a linked worktree is moved without
917 using <code>git worktree move</code>, the main worktree (or bare repository) will be
918 unable to locate it. Running <code>repair</code> within the recently-moved worktree
919 will reestablish the connection. If multiple linked worktrees are moved,
920 running <code>repair</code> from any worktree with each tree&#8217;s new <code>&lt;path&gt;</code> as an
921 argument, will reestablish the connection to all the specified paths.</p></div>
922 <div class="paragraph"><p>If both the main worktree and linked worktrees have been moved manually,
923 then running <code>repair</code> in the main worktree and specifying the new <code>&lt;path&gt;</code>
924 of each linked worktree will reestablish all connections in both
925 directions.</p></div>
926 </dd>
927 <dt class="hdlist1">
928 unlock
929 </dt>
930 <dd>
932 Unlock a worktree, allowing it to be pruned, moved or deleted.
933 </p>
934 </dd>
935 </dl></div>
936 </div>
937 </div>
938 <div class="sect1">
939 <h2 id="_options">OPTIONS</h2>
940 <div class="sectionbody">
941 <div class="dlist"><dl>
942 <dt class="hdlist1">
944 </dt>
945 <dt class="hdlist1">
946 --force
947 </dt>
948 <dd>
950 By default, <code>add</code> refuses to create a new worktree when
951 <code>&lt;commit-ish&gt;</code> is a branch name and is already checked out by
952 another worktree, or if <code>&lt;path&gt;</code> is already assigned to some
953 worktree but is missing (for instance, if <code>&lt;path&gt;</code> was deleted
954 manually). This option overrides these safeguards. To add a missing but
955 locked worktree path, specify <code>--force</code> twice.
956 </p>
957 <div class="paragraph"><p><code>move</code> refuses to move a locked worktree unless <code>--force</code> is specified
958 twice. If the destination is already assigned to some other worktree but is
959 missing (for instance, if <code>&lt;new-path&gt;</code> was deleted manually), then <code>--force</code>
960 allows the move to proceed; use <code>--force</code> twice if the destination is locked.</p></div>
961 <div class="paragraph"><p><code>remove</code> refuses to remove an unclean worktree unless <code>--force</code> is used.
962 To remove a locked worktree, specify <code>--force</code> twice.</p></div>
963 </dd>
964 <dt class="hdlist1">
965 -b &lt;new-branch&gt;
966 </dt>
967 <dt class="hdlist1">
968 -B &lt;new-branch&gt;
969 </dt>
970 <dd>
972 With <code>add</code>, create a new branch named <code>&lt;new-branch&gt;</code> starting at
973 <code>&lt;commit-ish&gt;</code>, and check out <code>&lt;new-branch&gt;</code> into the new worktree.
974 If <code>&lt;commit-ish&gt;</code> is omitted, it defaults to <code>HEAD</code>.
975 By default, <code>-b</code> refuses to create a new branch if it already
976 exists. <code>-B</code> overrides this safeguard, resetting <code>&lt;new-branch&gt;</code> to
977 <code>&lt;commit-ish&gt;</code>.
978 </p>
979 </dd>
980 <dt class="hdlist1">
982 </dt>
983 <dt class="hdlist1">
984 --detach
985 </dt>
986 <dd>
988 With <code>add</code>, detach <code>HEAD</code> in the new worktree. See "DETACHED HEAD"
989 in <a href="git-checkout.html">git-checkout(1)</a>.
990 </p>
991 </dd>
992 <dt class="hdlist1">
993 --[no-]checkout
994 </dt>
995 <dd>
997 By default, <code>add</code> checks out <code>&lt;commit-ish&gt;</code>, however, <code>--no-checkout</code> can
998 be used to suppress checkout in order to make customizations,
999 such as configuring sparse-checkout. See "Sparse checkout"
1000 in <a href="git-read-tree.html">git-read-tree(1)</a>.
1001 </p>
1002 </dd>
1003 <dt class="hdlist1">
1004 --[no-]guess-remote
1005 </dt>
1006 <dd>
1008 With <code>worktree add &lt;path&gt;</code>, without <code>&lt;commit-ish&gt;</code>, instead
1009 of creating a new branch from <code>HEAD</code>, if there exists a tracking
1010 branch in exactly one remote matching the basename of <code>&lt;path&gt;</code>,
1011 base the new branch on the remote-tracking branch, and mark
1012 the remote-tracking branch as "upstream" from the new branch.
1013 </p>
1014 <div class="paragraph"><p>This can also be set up as the default behaviour by using the
1015 <code>worktree.guessRemote</code> config option.</p></div>
1016 </dd>
1017 <dt class="hdlist1">
1018 --[no-]track
1019 </dt>
1020 <dd>
1022 When creating a new branch, if <code>&lt;commit-ish&gt;</code> is a branch,
1023 mark it as "upstream" from the new branch. This is the
1024 default if <code>&lt;commit-ish&gt;</code> is a remote-tracking branch. See
1025 <code>--track</code> in <a href="git-branch.html">git-branch(1)</a> for details.
1026 </p>
1027 </dd>
1028 <dt class="hdlist1">
1029 --lock
1030 </dt>
1031 <dd>
1033 Keep the worktree locked after creation. This is the
1034 equivalent of <code>git worktree lock</code> after <code>git worktree add</code>,
1035 but without a race condition.
1036 </p>
1037 </dd>
1038 <dt class="hdlist1">
1040 </dt>
1041 <dt class="hdlist1">
1042 --dry-run
1043 </dt>
1044 <dd>
1046 With <code>prune</code>, do not remove anything; just report what it would
1047 remove.
1048 </p>
1049 </dd>
1050 <dt class="hdlist1">
1051 --orphan
1052 </dt>
1053 <dd>
1055 With <code>add</code>, make the new worktree and index empty, associating
1056 the worktree with a new unborn branch named <code>&lt;new-branch&gt;</code>.
1057 </p>
1058 </dd>
1059 <dt class="hdlist1">
1060 --porcelain
1061 </dt>
1062 <dd>
1064 With <code>list</code>, output in an easy-to-parse format for scripts.
1065 This format will remain stable across Git versions and regardless of user
1066 configuration. It is recommended to combine this with <code>-z</code>.
1067 See below for details.
1068 </p>
1069 </dd>
1070 <dt class="hdlist1">
1072 </dt>
1073 <dd>
1075 Terminate each line with a NUL rather than a newline when
1076 <code>--porcelain</code> is specified with <code>list</code>. This makes it possible
1077 to parse the output when a worktree path contains a newline
1078 character.
1079 </p>
1080 </dd>
1081 <dt class="hdlist1">
1083 </dt>
1084 <dt class="hdlist1">
1085 --quiet
1086 </dt>
1087 <dd>
1089 With <code>add</code>, suppress feedback messages.
1090 </p>
1091 </dd>
1092 <dt class="hdlist1">
1094 </dt>
1095 <dt class="hdlist1">
1096 --verbose
1097 </dt>
1098 <dd>
1100 With <code>prune</code>, report all removals.
1101 </p>
1102 <div class="paragraph"><p>With <code>list</code>, output additional information about worktrees (see below).</p></div>
1103 </dd>
1104 <dt class="hdlist1">
1105 --expire &lt;time&gt;
1106 </dt>
1107 <dd>
1109 With <code>prune</code>, only expire unused worktrees older than <code>&lt;time&gt;</code>.
1110 </p>
1111 <div class="paragraph"><p>With <code>list</code>, annotate missing worktrees as prunable if they are older than
1112 <code>&lt;time&gt;</code>.</p></div>
1113 </dd>
1114 <dt class="hdlist1">
1115 --reason &lt;string&gt;
1116 </dt>
1117 <dd>
1119 With <code>lock</code> or with <code>add --lock</code>, an explanation why the worktree
1120 is locked.
1121 </p>
1122 </dd>
1123 <dt class="hdlist1">
1124 &lt;worktree&gt;
1125 </dt>
1126 <dd>
1128 Worktrees can be identified by path, either relative or absolute.
1129 </p>
1130 <div class="paragraph"><p>If the last path components in the worktree&#8217;s path is unique among
1131 worktrees, it can be used to identify a worktree. For example if you only
1132 have two worktrees, at <code>/abc/def/ghi</code> and <code>/abc/def/ggg</code>, then <code>ghi</code> or
1133 <code>def/ghi</code> is enough to point to the former worktree.</p></div>
1134 </dd>
1135 </dl></div>
1136 </div>
1137 </div>
1138 <div class="sect1">
1139 <h2 id="_refs">REFS</h2>
1140 <div class="sectionbody">
1141 <div class="paragraph"><p>When using multiple worktrees, some refs are shared between all worktrees,
1142 but others are specific to an individual worktree. One example is <code>HEAD</code>,
1143 which is different for each worktree. This section is about the sharing
1144 rules and how to access refs of one worktree from another.</p></div>
1145 <div class="paragraph"><p>In general, all pseudo refs are per-worktree and all refs starting with
1146 <code>refs/</code> are shared. Pseudo refs are ones like <code>HEAD</code> which are directly
1147 under <code>$GIT_DIR</code> instead of inside <code>$GIT_DIR/refs</code>. There are exceptions,
1148 however: refs inside <code>refs/bisect</code>, <code>refs/worktree</code> and <code>refs/rewritten</code> are
1149 not shared.</p></div>
1150 <div class="paragraph"><p>Refs that are per-worktree can still be accessed from another worktree via
1151 two special paths, <code>main-worktree</code> and <code>worktrees</code>. The former gives
1152 access to per-worktree refs of the main worktree, while the latter to all
1153 linked worktrees.</p></div>
1154 <div class="paragraph"><p>For example, <code>main-worktree/HEAD</code> or <code>main-worktree/refs/bisect/good</code>
1155 resolve to the same value as the main worktree&#8217;s <code>HEAD</code> and
1156 <code>refs/bisect/good</code> respectively. Similarly, <code>worktrees/foo/HEAD</code> or
1157 <code>worktrees/bar/refs/bisect/bad</code> are the same as
1158 <code>$GIT_COMMON_DIR/worktrees/foo/HEAD</code> and
1159 <code>$GIT_COMMON_DIR/worktrees/bar/refs/bisect/bad</code>.</p></div>
1160 <div class="paragraph"><p>To access refs, it&#8217;s best not to look inside <code>$GIT_DIR</code> directly. Instead
1161 use commands such as <a href="git-rev-parse.html">git-rev-parse(1)</a> or <a href="git-update-ref.html">git-update-ref(1)</a>
1162 which will handle refs correctly.</p></div>
1163 </div>
1164 </div>
1165 <div class="sect1">
1166 <h2 id="_configuration_file">CONFIGURATION FILE</h2>
1167 <div class="sectionbody">
1168 <div class="paragraph"><p>By default, the repository <code>config</code> file is shared across all worktrees.
1169 If the config variables <code>core.bare</code> or <code>core.worktree</code> are present in the
1170 common config file and <code>extensions.worktreeConfig</code> is disabled, then they
1171 will be applied to the main worktree only.</p></div>
1172 <div class="paragraph"><p>In order to have worktree-specific configuration, you can turn on the
1173 <code>worktreeConfig</code> extension, e.g.:</p></div>
1174 <div class="listingblock">
1175 <div class="content">
1176 <pre><code>$ git config extensions.worktreeConfig true</code></pre>
1177 </div></div>
1178 <div class="paragraph"><p>In this mode, specific configuration stays in the path pointed by <code>git
1179 rev-parse --git-path config.worktree</code>. You can add or update
1180 configuration in this file with <code>git config --worktree</code>. Older Git
1181 versions will refuse to access repositories with this extension.</p></div>
1182 <div class="paragraph"><p>Note that in this file, the exception for <code>core.bare</code> and <code>core.worktree</code>
1183 is gone. If they exist in <code>$GIT_DIR/config</code>, you must move
1184 them to the <code>config.worktree</code> of the main worktree. You may also take this
1185 opportunity to review and move other configuration that you do not want to
1186 share to all worktrees:</p></div>
1187 <div class="ulist"><ul>
1188 <li>
1190 <code>core.worktree</code> should never be shared.
1191 </p>
1192 </li>
1193 <li>
1195 <code>core.bare</code> should not be shared if the value is <code>core.bare=true</code>.
1196 </p>
1197 </li>
1198 <li>
1200 <code>core.sparseCheckout</code> should not be shared, unless you are sure you
1201 always use sparse checkout for all worktrees.
1202 </p>
1203 </li>
1204 </ul></div>
1205 <div class="paragraph"><p>See the documentation of <code>extensions.worktreeConfig</code> in
1206 <a href="git-config.html">git-config(1)</a> for more details.</p></div>
1207 </div>
1208 </div>
1209 <div class="sect1">
1210 <h2 id="_details">DETAILS</h2>
1211 <div class="sectionbody">
1212 <div class="paragraph"><p>Each linked worktree has a private sub-directory in the repository&#8217;s
1213 <code>$GIT_DIR/worktrees</code> directory. The private sub-directory&#8217;s name is usually
1214 the base name of the linked worktree&#8217;s path, possibly appended with a
1215 number to make it unique. For example, when <code>$GIT_DIR=/path/main/.git</code> the
1216 command <code>git worktree add /path/other/test-next next</code> creates the linked
1217 worktree in <code>/path/other/test-next</code> and also creates a
1218 <code>$GIT_DIR/worktrees/test-next</code> directory (or <code>$GIT_DIR/worktrees/test-next1</code>
1219 if <code>test-next</code> is already taken).</p></div>
1220 <div class="paragraph"><p>Within a linked worktree, <code>$GIT_DIR</code> is set to point to this private
1221 directory (e.g. <code>/path/main/.git/worktrees/test-next</code> in the example) and
1222 <code>$GIT_COMMON_DIR</code> is set to point back to the main worktree&#8217;s <code>$GIT_DIR</code>
1223 (e.g. <code>/path/main/.git</code>). These settings are made in a <code>.git</code> file located at
1224 the top directory of the linked worktree.</p></div>
1225 <div class="paragraph"><p>Path resolution via <code>git rev-parse --git-path</code> uses either
1226 <code>$GIT_DIR</code> or <code>$GIT_COMMON_DIR</code> depending on the path. For example, in the
1227 linked worktree <code>git rev-parse --git-path HEAD</code> returns
1228 <code>/path/main/.git/worktrees/test-next/HEAD</code> (not
1229 <code>/path/other/test-next/.git/HEAD</code> or <code>/path/main/.git/HEAD</code>) while <code>git
1230 rev-parse --git-path refs/heads/master</code> uses
1231 <code>$GIT_COMMON_DIR</code> and returns <code>/path/main/.git/refs/heads/master</code>,
1232 since refs are shared across all worktrees, except <code>refs/bisect</code>,
1233 <code>refs/worktree</code> and <code>refs/rewritten</code>.</p></div>
1234 <div class="paragraph"><p>See <a href="gitrepository-layout.html">gitrepository-layout(5)</a> for more information. The rule of
1235 thumb is do not make any assumption about whether a path belongs to
1236 <code>$GIT_DIR</code> or <code>$GIT_COMMON_DIR</code> when you need to directly access something
1237 inside <code>$GIT_DIR</code>. Use <code>git rev-parse --git-path</code> to get the final path.</p></div>
1238 <div class="paragraph"><p>If you manually move a linked worktree, you need to update the <code>gitdir</code> file
1239 in the entry&#8217;s directory. For example, if a linked worktree is moved
1240 to <code>/newpath/test-next</code> and its <code>.git</code> file points to
1241 <code>/path/main/.git/worktrees/test-next</code>, then update
1242 <code>/path/main/.git/worktrees/test-next/gitdir</code> to reference <code>/newpath/test-next</code>
1243 instead. Better yet, run <code>git worktree repair</code> to reestablish the connection
1244 automatically.</p></div>
1245 <div class="paragraph"><p>To prevent a <code>$GIT_DIR/worktrees</code> entry from being pruned (which
1246 can be useful in some situations, such as when the
1247 entry&#8217;s worktree is stored on a portable device), use the
1248 <code>git worktree lock</code> command, which adds a file named
1249 <code>locked</code> to the entry&#8217;s directory. The file contains the reason in
1250 plain text. For example, if a linked worktree&#8217;s <code>.git</code> file points
1251 to <code>/path/main/.git/worktrees/test-next</code> then a file named
1252 <code>/path/main/.git/worktrees/test-next/locked</code> will prevent the
1253 <code>test-next</code> entry from being pruned. See
1254 <a href="gitrepository-layout.html">gitrepository-layout(5)</a> for details.</p></div>
1255 <div class="paragraph"><p>When <code>extensions.worktreeConfig</code> is enabled, the config file
1256 <code>.git/worktrees/&lt;id&gt;/config.worktree</code> is read after <code>.git/config</code> is.</p></div>
1257 </div>
1258 </div>
1259 <div class="sect1">
1260 <h2 id="_list_output_format">LIST OUTPUT FORMAT</h2>
1261 <div class="sectionbody">
1262 <div class="paragraph"><p>The <code>worktree list</code> command has two output formats. The default format shows the
1263 details on a single line with columns. For example:</p></div>
1264 <div class="listingblock">
1265 <div class="content">
1266 <pre><code>$ git worktree list
1267 /path/to/bare-source (bare)
1268 /path/to/linked-worktree abcd1234 [master]
1269 /path/to/other-linked-worktree 1234abc (detached HEAD)</code></pre>
1270 </div></div>
1271 <div class="paragraph"><p>The command also shows annotations for each worktree, according to its state.
1272 These annotations are:</p></div>
1273 <div class="ulist"><ul>
1274 <li>
1276 <code>locked</code>, if the worktree is locked.
1277 </p>
1278 </li>
1279 <li>
1281 <code>prunable</code>, if the worktree can be pruned via <code>git worktree prune</code>.
1282 </p>
1283 </li>
1284 </ul></div>
1285 <div class="listingblock">
1286 <div class="content">
1287 <pre><code>$ git worktree list
1288 /path/to/linked-worktree abcd1234 [master]
1289 /path/to/locked-worktree acbd5678 (brancha) locked
1290 /path/to/prunable-worktree 5678abc (detached HEAD) prunable</code></pre>
1291 </div></div>
1292 <div class="paragraph"><p>For these annotations, a reason might also be available and this can be
1293 seen using the verbose mode. The annotation is then moved to the next line
1294 indented followed by the additional information.</p></div>
1295 <div class="listingblock">
1296 <div class="content">
1297 <pre><code>$ git worktree list --verbose
1298 /path/to/linked-worktree abcd1234 [master]
1299 /path/to/locked-worktree-no-reason abcd5678 (detached HEAD) locked
1300 /path/to/locked-worktree-with-reason 1234abcd (brancha)
1301 locked: worktree path is mounted on a portable device
1302 /path/to/prunable-worktree 5678abc1 (detached HEAD)
1303 prunable: gitdir file points to non-existent location</code></pre>
1304 </div></div>
1305 <div class="paragraph"><p>Note that the annotation is moved to the next line if the additional
1306 information is available, otherwise it stays on the same line as the
1307 worktree itself.</p></div>
1308 <div class="sect2">
1309 <h3 id="_porcelain_format">Porcelain Format</h3>
1310 <div class="paragraph"><p>The porcelain format has a line per attribute. If <code>-z</code> is given then the lines
1311 are terminated with NUL rather than a newline. Attributes are listed with a
1312 label and value separated by a single space. Boolean attributes (like <code>bare</code>
1313 and <code>detached</code>) are listed as a label only, and are present only
1314 if the value is true. Some attributes (like <code>locked</code>) can be listed as a label
1315 only or with a value depending upon whether a reason is available. The first
1316 attribute of a worktree is always <code>worktree</code>, an empty line indicates the
1317 end of the record. For example:</p></div>
1318 <div class="listingblock">
1319 <div class="content">
1320 <pre><code>$ git worktree list --porcelain
1321 worktree /path/to/bare-source
1322 bare
1324 worktree /path/to/linked-worktree
1325 HEAD abcd1234abcd1234abcd1234abcd1234abcd1234
1326 branch refs/heads/master
1328 worktree /path/to/other-linked-worktree
1329 HEAD 1234abc1234abc1234abc1234abc1234abc1234a
1330 detached
1332 worktree /path/to/linked-worktree-locked-no-reason
1333 HEAD 5678abc5678abc5678abc5678abc5678abc5678c
1334 branch refs/heads/locked-no-reason
1335 locked
1337 worktree /path/to/linked-worktree-locked-with-reason
1338 HEAD 3456def3456def3456def3456def3456def3456b
1339 branch refs/heads/locked-with-reason
1340 locked reason why is locked
1342 worktree /path/to/linked-worktree-prunable
1343 HEAD 1233def1234def1234def1234def1234def1234b
1344 detached
1345 prunable gitdir file points to non-existent location</code></pre>
1346 </div></div>
1347 <div class="paragraph"><p>Unless <code>-z</code> is used any "unusual" characters in the lock reason such as newlines
1348 are escaped and the entire reason is quoted as explained for the
1349 configuration variable <code>core.quotePath</code> (see <a href="git-config.html">git-config(1)</a>).
1350 For Example:</p></div>
1351 <div class="listingblock">
1352 <div class="content">
1353 <pre><code>$ git worktree list --porcelain
1355 locked "reason\nwhy is locked"
1356 ...</code></pre>
1357 </div></div>
1358 </div>
1359 </div>
1360 </div>
1361 <div class="sect1">
1362 <h2 id="_examples">EXAMPLES</h2>
1363 <div class="sectionbody">
1364 <div class="paragraph"><p>You are in the middle of a refactoring session and your boss comes in and
1365 demands that you fix something immediately. You might typically use
1366 <a href="git-stash.html">git-stash(1)</a> to store your changes away temporarily, however, your
1367 working tree is in such a state of disarray (with new, moved, and removed
1368 files, and other bits and pieces strewn around) that you don&#8217;t want to risk
1369 disturbing any of it. Instead, you create a temporary linked worktree to
1370 make the emergency fix, remove it when done, and then resume your earlier
1371 refactoring session.</p></div>
1372 <div class="listingblock">
1373 <div class="content">
1374 <pre><code>$ git worktree add -b emergency-fix ../temp master
1375 $ pushd ../temp
1376 # ... hack hack hack ...
1377 $ git commit -a -m 'emergency fix for boss'
1378 $ popd
1379 $ git worktree remove ../temp</code></pre>
1380 </div></div>
1381 </div>
1382 </div>
1383 <div class="sect1">
1384 <h2 id="_bugs">BUGS</h2>
1385 <div class="sectionbody">
1386 <div class="paragraph"><p>Multiple checkout in general is still experimental, and the support
1387 for submodules is incomplete. It is NOT recommended to make multiple
1388 checkouts of a superproject.</p></div>
1389 </div>
1390 </div>
1391 <div class="sect1">
1392 <h2 id="_git">GIT</h2>
1393 <div class="sectionbody">
1394 <div class="paragraph"><p>Part of the <a href="git.html">git(1)</a> suite</p></div>
1395 </div>
1396 </div>
1397 </div>
1398 <div id="footnotes"><hr /></div>
1399 <div id="footer">
1400 <div id="footer-text">
1401 Last updated
1402 2024-01-02 14:28:43 PST
1403 </div>
1404 </div>
1405 </body>
1406 </html>