Autogenerated HTML docs for v2.42.0-325-g3a063
[git-htmldocs.git] / git-stash.html
blob3b9cfbe9cc6afaca5caa90f2214b40ccfee4a1cf
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-stash(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-stash(1) Manual Page
739 </h1>
740 <h2>NAME</h2>
741 <div class="sectionbody">
742 <p>git-stash -
743 Stash the changes in a dirty working directory away
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 stash</em> list [&lt;log-options&gt;]
753 <em>git stash</em> show [-u | --include-untracked | --only-untracked] [&lt;diff-options&gt;] [&lt;stash&gt;]
754 <em>git stash</em> drop [-q | --quiet] [&lt;stash&gt;]
755 <em>git stash</em> pop [--index] [-q | --quiet] [&lt;stash&gt;]
756 <em>git stash</em> apply [--index] [-q | --quiet] [&lt;stash&gt;]
757 <em>git stash</em> branch &lt;branchname&gt; [&lt;stash&gt;]
758 <em>git stash</em> [push [-p | --patch] [-S | --staged] [-k | --[no-]keep-index] [-q | --quiet]
759 [-u | --include-untracked] [-a | --all] [(-m | --message) &lt;message&gt;]
760 [--pathspec-from-file=&lt;file&gt; [--pathspec-file-nul]]
761 [--] [&lt;pathspec&gt;&#8230;]]
762 <em>git stash</em> save [-p | --patch] [-S | --staged] [-k | --[no-]keep-index] [-q | --quiet]
763 [-u | --include-untracked] [-a | --all] [&lt;message&gt;]
764 <em>git stash</em> clear
765 <em>git stash</em> create [&lt;message&gt;]
766 <em>git stash</em> store [(-m | --message) &lt;message&gt;] [-q | --quiet] &lt;commit&gt;</pre>
767 <div class="attribution">
768 </div></div>
769 </div>
770 </div>
771 <div class="sect1">
772 <h2 id="_description">DESCRIPTION</h2>
773 <div class="sectionbody">
774 <div class="paragraph"><p>Use <code>git stash</code> when you want to record the current state of the
775 working directory and the index, but want to go back to a clean
776 working directory. The command saves your local modifications away
777 and reverts the working directory to match the <code>HEAD</code> commit.</p></div>
778 <div class="paragraph"><p>The modifications stashed away by this command can be listed with
779 <code>git stash list</code>, inspected with <code>git stash show</code>, and restored
780 (potentially on top of a different commit) with <code>git stash apply</code>.
781 Calling <code>git stash</code> without any arguments is equivalent to <code>git stash push</code>.
782 A stash is by default listed as "WIP on <em>branchname</em> &#8230;", but
783 you can give a more descriptive message on the command line when
784 you create one.</p></div>
785 <div class="paragraph"><p>The latest stash you created is stored in <code>refs/stash</code>; older
786 stashes are found in the reflog of this reference and can be named using
787 the usual reflog syntax (e.g. <code>stash@{0}</code> is the most recently
788 created stash, <code>stash@{1}</code> is the one before it, <code>stash@{2.hours.ago}</code>
789 is also possible). Stashes may also be referenced by specifying just the
790 stash index (e.g. the integer <code>n</code> is equivalent to <code>stash@{n}</code>).</p></div>
791 </div>
792 </div>
793 <div class="sect1">
794 <h2 id="_commands">COMMANDS</h2>
795 <div class="sectionbody">
796 <div class="dlist"><dl>
797 <dt class="hdlist1">
798 push [-p|--patch] [-S|--staged] [-k|--[no-]keep-index] [-u|--include-untracked] [-a|--all] [-q|--quiet] [(-m|--message) &lt;message&gt;] [--pathspec-from-file=&lt;file&gt; [--pathspec-file-nul]] [--] [&lt;pathspec&gt;&#8230;]
799 </dt>
800 <dd>
802 Save your local modifications to a new <em>stash entry</em> and roll them
803 back to HEAD (in the working tree and in the index).
804 The &lt;message&gt; part is optional and gives
805 the description along with the stashed state.
806 </p>
807 <div class="paragraph"><p>For quickly making a snapshot, you can omit "push". In this mode,
808 non-option arguments are not allowed to prevent a misspelled
809 subcommand from making an unwanted stash entry. The two exceptions to this
810 are <code>stash -p</code> which acts as alias for <code>stash push -p</code> and pathspec elements,
811 which are allowed after a double hyphen <code>--</code> for disambiguation.</p></div>
812 </dd>
813 <dt class="hdlist1">
814 save [-p|--patch] [-S|--staged] [-k|--[no-]keep-index] [-u|--include-untracked] [-a|--all] [-q|--quiet] [&lt;message&gt;]
815 </dt>
816 <dd>
818 This option is deprecated in favour of <em>git stash push</em>. It
819 differs from "stash push" in that it cannot take pathspec.
820 Instead, all non-option arguments are concatenated to form the stash
821 message.
822 </p>
823 </dd>
824 <dt class="hdlist1">
825 list [&lt;log-options&gt;]
826 </dt>
827 <dd>
829 List the stash entries that you currently have. Each <em>stash entry</em> is
830 listed with its name (e.g. <code>stash@{0}</code> is the latest entry, <code>stash@{1}</code> is
831 the one before, etc.), the name of the branch that was current when the
832 entry was made, and a short description of the commit the entry was
833 based on.
834 </p>
835 <div class="listingblock">
836 <div class="content">
837 <pre><code>stash@{0}: WIP on submit: 6ebd0e2... Update git-stash documentation
838 stash@{1}: On master: 9cc0589... Add git-stash</code></pre>
839 </div></div>
840 <div class="paragraph"><p>The command takes options applicable to the <em>git log</em>
841 command to control what is shown and how. See <a href="git-log.html">git-log(1)</a>.</p></div>
842 </dd>
843 <dt class="hdlist1">
844 show [-u|--include-untracked|--only-untracked] [&lt;diff-options&gt;] [&lt;stash&gt;]
845 </dt>
846 <dd>
848 Show the changes recorded in the stash entry as a diff between the
849 stashed contents and the commit back when the stash entry was first
850 created.
851 By default, the command shows the diffstat, but it will accept any
852 format known to <em>git diff</em> (e.g., <code>git stash show -p stash@{1}</code>
853 to view the second most recent entry in patch form).
854 If no <code>&lt;diff-option&gt;</code> is provided, the default behavior will be given
855 by the <code>stash.showStat</code>, and <code>stash.showPatch</code> config variables. You
856 can also use <code>stash.showIncludeUntracked</code> to set whether
857 <code>--include-untracked</code> is enabled by default.
858 </p>
859 </dd>
860 <dt class="hdlist1">
861 pop [--index] [-q|--quiet] [&lt;stash&gt;]
862 </dt>
863 <dd>
865 Remove a single stashed state from the stash list and apply it
866 on top of the current working tree state, i.e., do the inverse
867 operation of <code>git stash push</code>. The working directory must
868 match the index.
869 </p>
870 <div class="paragraph"><p>Applying the state can fail with conflicts; in this case, it is not
871 removed from the stash list. You need to resolve the conflicts by hand
872 and call <code>git stash drop</code> manually afterwards.</p></div>
873 </dd>
874 <dt class="hdlist1">
875 apply [--index] [-q|--quiet] [&lt;stash&gt;]
876 </dt>
877 <dd>
879 Like <code>pop</code>, but do not remove the state from the stash list. Unlike <code>pop</code>,
880 <code>&lt;stash&gt;</code> may be any commit that looks like a commit created by
881 <code>stash push</code> or <code>stash create</code>.
882 </p>
883 </dd>
884 <dt class="hdlist1">
885 branch &lt;branchname&gt; [&lt;stash&gt;]
886 </dt>
887 <dd>
889 Creates and checks out a new branch named <code>&lt;branchname&gt;</code> starting from
890 the commit at which the <code>&lt;stash&gt;</code> was originally created, applies the
891 changes recorded in <code>&lt;stash&gt;</code> to the new working tree and index.
892 If that succeeds, and <code>&lt;stash&gt;</code> is a reference of the form
893 <code>stash@{&lt;revision&gt;}</code>, it then drops the <code>&lt;stash&gt;</code>.
894 </p>
895 <div class="paragraph"><p>This is useful if the branch on which you ran <code>git stash push</code> has
896 changed enough that <code>git stash apply</code> fails due to conflicts. Since
897 the stash entry is applied on top of the commit that was HEAD at the
898 time <code>git stash</code> was run, it restores the originally stashed state
899 with no conflicts.</p></div>
900 </dd>
901 <dt class="hdlist1">
902 clear
903 </dt>
904 <dd>
906 Remove all the stash entries. Note that those entries will then
907 be subject to pruning, and may be impossible to recover (see
908 <em>Examples</em> below for a possible strategy).
909 </p>
910 </dd>
911 <dt class="hdlist1">
912 drop [-q|--quiet] [&lt;stash&gt;]
913 </dt>
914 <dd>
916 Remove a single stash entry from the list of stash entries.
917 </p>
918 </dd>
919 <dt class="hdlist1">
920 create
921 </dt>
922 <dd>
924 Create a stash entry (which is a regular commit object) and
925 return its object name, without storing it anywhere in the ref
926 namespace.
927 This is intended to be useful for scripts. It is probably not
928 the command you want to use; see "push" above.
929 </p>
930 </dd>
931 <dt class="hdlist1">
932 store
933 </dt>
934 <dd>
936 Store a given stash created via <em>git stash create</em> (which is a
937 dangling merge commit) in the stash ref, updating the stash
938 reflog. This is intended to be useful for scripts. It is
939 probably not the command you want to use; see "push" above.
940 </p>
941 </dd>
942 </dl></div>
943 </div>
944 </div>
945 <div class="sect1">
946 <h2 id="_options">OPTIONS</h2>
947 <div class="sectionbody">
948 <div class="dlist"><dl>
949 <dt class="hdlist1">
951 </dt>
952 <dt class="hdlist1">
953 --all
954 </dt>
955 <dd>
957 This option is only valid for <code>push</code> and <code>save</code> commands.
958 </p>
959 <div class="paragraph"><p>All ignored and untracked files are also stashed and then cleaned
960 up with <code>git clean</code>.</p></div>
961 </dd>
962 <dt class="hdlist1">
964 </dt>
965 <dt class="hdlist1">
966 --include-untracked
967 </dt>
968 <dt class="hdlist1">
969 --no-include-untracked
970 </dt>
971 <dd>
973 When used with the <code>push</code> and <code>save</code> commands,
974 all untracked files are also stashed and then cleaned up with
975 <code>git clean</code>.
976 </p>
977 <div class="paragraph"><p>When used with the <code>show</code> command, show the untracked files in the stash
978 entry as part of the diff.</p></div>
979 </dd>
980 <dt class="hdlist1">
981 --only-untracked
982 </dt>
983 <dd>
985 This option is only valid for the <code>show</code> command.
986 </p>
987 <div class="paragraph"><p>Show only the untracked files in the stash entry as part of the diff.</p></div>
988 </dd>
989 <dt class="hdlist1">
990 --index
991 </dt>
992 <dd>
994 This option is only valid for <code>pop</code> and <code>apply</code> commands.
995 </p>
996 <div class="paragraph"><p>Tries to reinstate not only the working tree&#8217;s changes, but also
997 the index&#8217;s ones. However, this can fail, when you have conflicts
998 (which are stored in the index, where you therefore can no longer
999 apply the changes as they were originally).</p></div>
1000 </dd>
1001 <dt class="hdlist1">
1003 </dt>
1004 <dt class="hdlist1">
1005 --keep-index
1006 </dt>
1007 <dt class="hdlist1">
1008 --no-keep-index
1009 </dt>
1010 <dd>
1012 This option is only valid for <code>push</code> and <code>save</code> commands.
1013 </p>
1014 <div class="paragraph"><p>All changes already added to the index are left intact.</p></div>
1015 </dd>
1016 <dt class="hdlist1">
1018 </dt>
1019 <dt class="hdlist1">
1020 --patch
1021 </dt>
1022 <dd>
1024 This option is only valid for <code>push</code> and <code>save</code> commands.
1025 </p>
1026 <div class="paragraph"><p>Interactively select hunks from the diff between HEAD and the
1027 working tree to be stashed. The stash entry is constructed such
1028 that its index state is the same as the index state of your
1029 repository, and its worktree contains only the changes you selected
1030 interactively. The selected changes are then rolled back from your
1031 worktree. See the &#8220;Interactive Mode&#8221; section of <a href="git-add.html">git-add(1)</a>
1032 to learn how to operate the <code>--patch</code> mode.</p></div>
1033 <div class="paragraph"><p>The <code>--patch</code> option implies <code>--keep-index</code>. You can use
1034 <code>--no-keep-index</code> to override this.</p></div>
1035 </dd>
1036 <dt class="hdlist1">
1038 </dt>
1039 <dt class="hdlist1">
1040 --staged
1041 </dt>
1042 <dd>
1044 This option is only valid for <code>push</code> and <code>save</code> commands.
1045 </p>
1046 <div class="paragraph"><p>Stash only the changes that are currently staged. This is similar to
1047 basic <code>git commit</code> except the state is committed to the stash instead
1048 of current branch.</p></div>
1049 <div class="paragraph"><p>The <code>--patch</code> option has priority over this one.</p></div>
1050 </dd>
1051 <dt class="hdlist1">
1052 --pathspec-from-file=&lt;file&gt;
1053 </dt>
1054 <dd>
1056 This option is only valid for <code>push</code> command.
1057 </p>
1058 <div class="paragraph"><p>Pathspec is passed in <code>&lt;file&gt;</code> instead of commandline args. If
1059 <code>&lt;file&gt;</code> is exactly <code>-</code> then standard input is used. Pathspec
1060 elements are separated by LF or CR/LF. Pathspec elements can be
1061 quoted as explained for the configuration variable <code>core.quotePath</code>
1062 (see <a href="git-config.html">git-config(1)</a>). See also <code>--pathspec-file-nul</code> and
1063 global <code>--literal-pathspecs</code>.</p></div>
1064 </dd>
1065 <dt class="hdlist1">
1066 --pathspec-file-nul
1067 </dt>
1068 <dd>
1070 This option is only valid for <code>push</code> command.
1071 </p>
1072 <div class="paragraph"><p>Only meaningful with <code>--pathspec-from-file</code>. Pathspec elements are
1073 separated with NUL character and all other characters are taken
1074 literally (including newlines and quotes).</p></div>
1075 </dd>
1076 <dt class="hdlist1">
1078 </dt>
1079 <dt class="hdlist1">
1080 --quiet
1081 </dt>
1082 <dd>
1084 This option is only valid for <code>apply</code>, <code>drop</code>, <code>pop</code>, <code>push</code>,
1085 <code>save</code>, <code>store</code> commands.
1086 </p>
1087 <div class="paragraph"><p>Quiet, suppress feedback messages.</p></div>
1088 </dd>
1089 <dt class="hdlist1">
1091 </dt>
1092 <dd>
1094 This option is only valid for <code>push</code> command.
1095 </p>
1096 <div class="paragraph"><p>Separates pathspec from options for disambiguation purposes.</p></div>
1097 </dd>
1098 <dt class="hdlist1">
1099 &lt;pathspec&gt;&#8230;
1100 </dt>
1101 <dd>
1103 This option is only valid for <code>push</code> command.
1104 </p>
1105 <div class="paragraph"><p>The new stash entry records the modified states only for the files
1106 that match the pathspec. The index entries and working tree files
1107 are then rolled back to the state in HEAD only for these files,
1108 too, leaving files that do not match the pathspec intact.</p></div>
1109 <div class="paragraph"><p>For more details, see the <em>pathspec</em> entry in <a href="gitglossary.html">gitglossary(7)</a>.</p></div>
1110 </dd>
1111 <dt class="hdlist1">
1112 &lt;stash&gt;
1113 </dt>
1114 <dd>
1116 This option is only valid for <code>apply</code>, <code>branch</code>, <code>drop</code>, <code>pop</code>,
1117 <code>show</code> commands.
1118 </p>
1119 <div class="paragraph"><p>A reference of the form <code>stash@{&lt;revision&gt;}</code>. When no <code>&lt;stash&gt;</code> is
1120 given, the latest stash is assumed (that is, <code>stash@{0}</code>).</p></div>
1121 </dd>
1122 </dl></div>
1123 </div>
1124 </div>
1125 <div class="sect1">
1126 <h2 id="_discussion">DISCUSSION</h2>
1127 <div class="sectionbody">
1128 <div class="paragraph"><p>A stash entry is represented as a commit whose tree records the state
1129 of the working directory, and its first parent is the commit at <code>HEAD</code>
1130 when the entry was created. The tree of the second parent records the
1131 state of the index when the entry is made, and it is made a child of
1132 the <code>HEAD</code> commit. The ancestry graph looks like this:</p></div>
1133 <div class="literalblock">
1134 <div class="content">
1135 <pre><code> .----W
1137 -----H----I</code></pre>
1138 </div></div>
1139 <div class="paragraph"><p>where <code>H</code> is the <code>HEAD</code> commit, <code>I</code> is a commit that records the state
1140 of the index, and <code>W</code> is a commit that records the state of the working
1141 tree.</p></div>
1142 </div>
1143 </div>
1144 <div class="sect1">
1145 <h2 id="_examples">EXAMPLES</h2>
1146 <div class="sectionbody">
1147 <div class="dlist"><dl>
1148 <dt class="hdlist1">
1149 Pulling into a dirty tree
1150 </dt>
1151 <dd>
1153 When you are in the middle of something, you learn that there are
1154 upstream changes that are possibly relevant to what you are
1155 doing. When your local changes do not conflict with the changes in
1156 the upstream, a simple <code>git pull</code> will let you move forward.
1157 </p>
1158 <div class="paragraph"><p>However, there are cases in which your local changes do conflict with
1159 the upstream changes, and <code>git pull</code> refuses to overwrite your
1160 changes. In such a case, you can stash your changes away,
1161 perform a pull, and then unstash, like this:</p></div>
1162 <div class="listingblock">
1163 <div class="content">
1164 <pre><code>$ git pull
1166 file foobar not up to date, cannot merge.
1167 $ git stash
1168 $ git pull
1169 $ git stash pop</code></pre>
1170 </div></div>
1171 </dd>
1172 <dt class="hdlist1">
1173 Interrupted workflow
1174 </dt>
1175 <dd>
1177 When you are in the middle of something, your boss comes in and
1178 demands that you fix something immediately. Traditionally, you would
1179 make a commit to a temporary branch to store your changes away, and
1180 return to your original branch to make the emergency fix, like this:
1181 </p>
1182 <div class="listingblock">
1183 <div class="content">
1184 <pre><code># ... hack hack hack ...
1185 $ git switch -c my_wip
1186 $ git commit -a -m "WIP"
1187 $ git switch master
1188 $ edit emergency fix
1189 $ git commit -a -m "Fix in a hurry"
1190 $ git switch my_wip
1191 $ git reset --soft HEAD^
1192 # ... continue hacking ...</code></pre>
1193 </div></div>
1194 <div class="paragraph"><p>You can use <em>git stash</em> to simplify the above, like this:</p></div>
1195 <div class="listingblock">
1196 <div class="content">
1197 <pre><code># ... hack hack hack ...
1198 $ git stash
1199 $ edit emergency fix
1200 $ git commit -a -m "Fix in a hurry"
1201 $ git stash pop
1202 # ... continue hacking ...</code></pre>
1203 </div></div>
1204 </dd>
1205 <dt class="hdlist1">
1206 Testing partial commits
1207 </dt>
1208 <dd>
1210 You can use <code>git stash push --keep-index</code> when you want to make two or
1211 more commits out of the changes in the work tree, and you want to test
1212 each change before committing:
1213 </p>
1214 <div class="listingblock">
1215 <div class="content">
1216 <pre><code># ... hack hack hack ...
1217 $ git add --patch foo # add just first part to the index
1218 $ git stash push --keep-index # save all other changes to the stash
1219 $ edit/build/test first part
1220 $ git commit -m 'First part' # commit fully tested change
1221 $ git stash pop # prepare to work on all other changes
1222 # ... repeat above five steps until one commit remains ...
1223 $ edit/build/test remaining parts
1224 $ git commit foo -m 'Remaining parts'</code></pre>
1225 </div></div>
1226 </dd>
1227 <dt class="hdlist1">
1228 Saving unrelated changes for future use
1229 </dt>
1230 <dd>
1232 When you are in the middle of massive changes and you find some
1233 unrelated issue that you don&#8217;t want to forget to fix, you can do the
1234 change(s), stage them, and use <code>git stash push --staged</code> to stash them
1235 out for future use. This is similar to committing the staged changes,
1236 only the commit ends-up being in the stash and not on the current branch.
1237 </p>
1238 <div class="listingblock">
1239 <div class="content">
1240 <pre><code># ... hack hack hack ...
1241 $ git add --patch foo # add unrelated changes to the index
1242 $ git stash push --staged # save these changes to the stash
1243 # ... hack hack hack, finish current changes ...
1244 $ git commit -m 'Massive' # commit fully tested changes
1245 $ git switch fixup-branch # switch to another branch
1246 $ git stash pop # to finish work on the saved changes</code></pre>
1247 </div></div>
1248 </dd>
1249 <dt class="hdlist1">
1250 Recovering stash entries that were cleared/dropped erroneously
1251 </dt>
1252 <dd>
1254 If you mistakenly drop or clear stash entries, they cannot be recovered
1255 through the normal safety mechanisms. However, you can try the
1256 following incantation to get a list of stash entries that are still in
1257 your repository, but not reachable any more:
1258 </p>
1259 <div class="listingblock">
1260 <div class="content">
1261 <pre><code>git fsck --unreachable |
1262 grep commit | cut -d\ -f3 |
1263 xargs git log --merges --no-walk --grep=WIP</code></pre>
1264 </div></div>
1265 </dd>
1266 </dl></div>
1267 </div>
1268 </div>
1269 <div class="sect1">
1270 <h2 id="_configuration">CONFIGURATION</h2>
1271 <div class="sectionbody">
1272 <div class="paragraph"><p>Everything below this line in this section is selectively included
1273 from the <a href="git-config.html">git-config(1)</a> documentation. The content is the same
1274 as what&#8217;s found there:</p></div>
1275 <div class="dlist"><dl>
1276 <dt class="hdlist1">
1277 stash.showIncludeUntracked
1278 </dt>
1279 <dd>
1281 If this is set to true, the <code>git stash show</code> command will show
1282 the untracked files of a stash entry. Defaults to false. See
1283 description of <em>show</em> command in <a href="git-stash.html">git-stash(1)</a>.
1284 </p>
1285 </dd>
1286 <dt class="hdlist1">
1287 stash.showPatch
1288 </dt>
1289 <dd>
1291 If this is set to true, the <code>git stash show</code> command without an
1292 option will show the stash entry in patch form. Defaults to false.
1293 See description of <em>show</em> command in <a href="git-stash.html">git-stash(1)</a>.
1294 </p>
1295 </dd>
1296 <dt class="hdlist1">
1297 stash.showStat
1298 </dt>
1299 <dd>
1301 If this is set to true, the <code>git stash show</code> command without an
1302 option will show diffstat of the stash entry. Defaults to true.
1303 See description of <em>show</em> command in <a href="git-stash.html">git-stash(1)</a>.
1304 </p>
1305 </dd>
1306 </dl></div>
1307 </div>
1308 </div>
1309 <div class="sect1">
1310 <h2 id="_see_also">SEE ALSO</h2>
1311 <div class="sectionbody">
1312 <div class="paragraph"><p><a href="git-checkout.html">git-checkout(1)</a>,
1313 <a href="git-commit.html">git-commit(1)</a>,
1314 <a href="git-reflog.html">git-reflog(1)</a>,
1315 <a href="git-reset.html">git-reset(1)</a>,
1316 <a href="git-switch.html">git-switch(1)</a></p></div>
1317 </div>
1318 </div>
1319 <div class="sect1">
1320 <h2 id="_git">GIT</h2>
1321 <div class="sectionbody">
1322 <div class="paragraph"><p>Part of the <a href="git.html">git(1)</a> suite</p></div>
1323 </div>
1324 </div>
1325 </div>
1326 <div id="footnotes"><hr /></div>
1327 <div id="footer">
1328 <div id="footer-text">
1329 Last updated
1330 2023-06-23 13:24:09 PDT
1331 </div>
1332 </div>
1333 </body>
1334 </html>