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">
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 */
14 font-family: Georgia,serif;
18 h1, h2, h3, h4, h5, h6,
19 div.title, caption.title,
20 thead, p.table.header,
22 #author, #revnumber, #revdate, #revremark,
24 font-family: Arial,Helvetica,sans-serif;
28 margin:
1em
5%
1em
5%;
33 text-decoration: underline;
49 h1, h2, h3, h4, h5, h6 {
57 border-bottom:
2px solid silver;
77 border:
1px solid silver;
88 ul
> li { color: #aaa; }
89 ul
> li
> * { color: black; }
91 .monospaced, code, pre {
92 font-family:
"Courier New", Courier, monospace;
99 white-space: pre-wrap;
109 #revnumber, #revdate, #revremark {
114 border-top:
2px solid silver;
120 padding-bottom:
0.5em;
124 padding-bottom:
0.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 {
135 margin-bottom:
1.5em;
137 div.admonitionblock {
139 margin-bottom:
2.0em;
144 div.content { /* Block element content. */
148 /* Block element titles. */
149 div.title, caption.title {
154 margin-bottom:
0.5em;
160 td div.title:first-child {
163 div.content div.title:first-child {
166 div.content + div.title {
170 div.sidebarblock
> div.content {
172 border:
1px solid #dddddd;
173 border-left:
4px solid #f0f0f0;
177 div.listingblock
> div.content {
178 border:
1px solid #dddddd;
179 border-left:
5px solid #f0f0f0;
184 div.quoteblock, div.verseblock {
188 border-left:
5px solid #f0f0f0;
192 div.quoteblock
> div.attribution {
197 div.verseblock
> pre.content {
198 font-family: inherit;
201 div.verseblock
> div.attribution {
205 /* DEPRECATED: Pre version
8.2.7 verse style literal block. */
206 div.verseblock + div.attribution {
210 div.admonitionblock .icon {
214 text-decoration: underline;
216 padding-right:
0.5em;
218 div.admonitionblock td.content {
220 border-left:
3px solid #dddddd;
223 div.exampleblock
> div.content {
224 border-left:
3px solid #dddddd;
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; }
234 margin-bottom:
0.8em;
247 list-style-position: outside;
250 list-style-type: decimal;
253 list-style-type: lower-alpha;
256 list-style-type: upper-alpha;
259 list-style-type: lower-roman;
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 {
269 margin-bottom:
0.1em;
281 margin-bottom:
0.8em;
284 padding-bottom:
15px;
286 dt.hdlist1.strong, td.hdlist1.strong {
292 padding-right:
0.8em;
298 div.hdlist.compact tr {
307 .footnote, .footnoteref {
311 span.footnote, span.footnoteref {
312 vertical-align: super;
316 margin:
20px
0 20px
0;
320 #footnotes div.footnote {
326 border-top:
1px solid silver;
335 padding-right:
0.5em;
336 padding-bottom:
0.3em;
344 #footer-badges { display: none; }
348 margin-bottom:
2.5em;
356 margin-bottom:
0.1em;
359 div.toclevel0, div.toclevel1, div.toclevel2, div.toclevel3, div.toclevel4 {
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; }
427 margin-bottom:
1.5em;
429 div.tableblock
> table {
430 border:
3px solid #
527bbd;
432 thead, p.table.header {
439 /* Because the table frame attribute is overridden by CSS in most browsers. */
440 div.tableblock
> table[
frame=
"void"] {
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;
460 margin-bottom:
1.5em;
462 thead, p.tableblock.header {
473 border-color: #
527bbd;
474 border-collapse: collapse;
476 th.tableblock, td.tableblock {
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 {
498 th.tableblock.halign-center, td.tableblock.halign-center {
501 th.tableblock.halign-right, td.tableblock.halign-right {
505 th.tableblock.valign-top, td.tableblock.valign-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;
523 padding-bottom:
0.5em;
524 border-top:
2px solid silver;
525 border-bottom:
2px solid silver;
530 body.manpage div.sectionbody {
535 body.manpage div#toc { display: none; }
540 <script type=
"text/javascript">
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
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 */
562 toc: function (toclevels) {
564 function getText(el) {
566 for (var i = el.firstChild; i != null; i = i.nextSibling) {
567 if (i.nodeType ==
3 /* Node.TEXT_NODE */) // IE doesn't speak constants.
569 else if (i.firstChild != null)
575 function TocEntry(el, text, toclevel) {
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
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);
602 var toc = document.getElementById(
"toc");
607 // Delete existing TOC entries in case we're reloading the TOC.
608 var tocEntriesToRemove = [];
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");
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.
651 var noteholder = document.getElementById(
"footnotes");
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");
670 for (i=
0; i
<spans.length; i++) {
671 if (spans[i].className ==
"footnote") {
673 var note = spans[i].getAttribute(
"data-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];
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;
692 noteholder.parentNode.removeChild(noteholder);
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.
701 "[<a href='#_footnote_" + n +
702 "' title='View footnote' class='footnote'>" + n +
"</a>]";
708 install: function(toclevels) {
711 function reinstall() {
712 asciidoc.footnotes();
714 asciidoc.toc(toclevels);
718 function reinstallAndRemoveTimer() {
719 clearInterval(timerId);
723 timerId = setInterval(reinstall,
500);
724 if (document.addEventListener)
725 document.addEventListener(
"DOMContentLoaded", reinstallAndRemoveTimer, false);
727 window.onload = reinstallAndRemoveTimer;
735 <body class=
"manpage">
738 git-stash(
1) Manual Page
741 <div class=
"sectionbody">
743 Stash the changes in a dirty working directory away
749 <h2 id=
"_synopsis">SYNOPSIS
</h2>
750 <div class=
"sectionbody">
751 <div class=
"verseblock">
752 <pre class=
"content"><em>git stash
</em> list [
<log-options
>]
753 <em>git stash
</em> show [-u | --include-untracked | --only-untracked] [
<diff-options
>] [
<stash
>]
754 <em>git stash
</em> drop [-q | --quiet] [
<stash
>]
755 <em>git stash
</em> pop [--index] [-q | --quiet] [
<stash
>]
756 <em>git stash
</em> apply [--index] [-q | --quiet] [
<stash
>]
757 <em>git stash
</em> branch
<branchname
> [
<stash
>]
758 <em>git stash
</em> [push [-p | --patch] [-S | --staged] [-k | --[no-]keep-index] [-q | --quiet]
759 [-u | --include-untracked] [-a | --all] [(-m | --message)
<message
>]
760 [--pathspec-from-file=
<file
> [--pathspec-file-nul]]
761 [--] [
<pathspec
>…]]
762 <em>git stash
</em> save [-p | --patch] [-S | --staged] [-k | --[no-]keep-index] [-q | --quiet]
763 [-u | --include-untracked] [-a | --all] [
<message
>]
764 <em>git stash
</em> clear
765 <em>git stash
</em> create [
<message
>]
766 <em>git stash
</em> store [(-m | --message)
<message
>] [-q | --quiet]
<commit
></pre>
767 <div class=
"attribution">
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> …", 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>
794 <h2 id=
"_commands">COMMANDS
</h2>
795 <div class=
"sectionbody">
796 <div class=
"dlist"><dl>
798 push [-p|--patch] [-S|--staged] [-k|--[no-]keep-index] [-u|--include-untracked] [-a|--all] [-q|--quiet] [(-m|--message)
<message
>] [--pathspec-from-file=
<file
> [--pathspec-file-nul]] [--] [
<pathspec
>…]
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
<message
> part is optional and gives
805 the description along with the stashed state.
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>
814 save [-p|--patch] [-S|--staged] [-k|--[no-]keep-index] [-u|--include-untracked] [-a|--all] [-q|--quiet] [
<message
>]
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
825 list [
<log-options
>]
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
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>
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>
844 show [-u|--include-untracked|--only-untracked] [
<diff-options
>] [
<stash
>]
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
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><diff-option
></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.
861 pop [--index] [-q|--quiet] [
<stash
>]
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
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>
875 apply [--index] [-q|--quiet] [
<stash
>]
879 Like
<code>pop
</code>, but do not remove the state from the stash list. Unlike
<code>pop
</code>,
880 <code><stash
></code> may be any commit that looks like a commit created by
881 <code>stash push
</code> or
<code>stash create
</code>.
885 branch
<branchname
> [
<stash
>]
889 Creates and checks out a new branch named
<code><branchname
></code> starting from
890 the commit at which the
<code><stash
></code> was originally created, applies the
891 changes recorded in
<code><stash
></code> to the new working tree and index.
892 If that succeeds, and
<code><stash
></code> is a reference of the form
893 <code>stash@{
<revision
>}
</code>, it then drops the
<code><stash
></code>.
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>
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).
912 drop [-q|--quiet] [
<stash
>]
916 Remove a single stash entry from the list of stash entries.
924 Create a stash entry (which is a regular commit object) and
925 return its object name, without storing it anywhere in the ref
927 This is intended to be useful for scripts. It is probably not
928 the command you want to use; see
"push" above.
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.
946 <h2 id=
"_options">OPTIONS
</h2>
947 <div class=
"sectionbody">
948 <div class=
"dlist"><dl>
957 This option is only valid for
<code>push
</code> and
<code>save
</code> commands.
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>
969 --no-include-untracked
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>.
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>
985 This option is only valid for the
<code>show
</code> command.
987 <div class=
"paragraph"><p>Show only the untracked files in the stash entry as part of the diff.
</p></div>
994 This option is only valid for
<code>pop
</code> and
<code>apply
</code> commands.
996 <div class=
"paragraph"><p>Tries to reinstate not only the working tree
’s changes, but also
997 the index
’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>
1001 <dt class=
"hdlist1">
1004 <dt class=
"hdlist1">
1007 <dt class=
"hdlist1">
1012 This option is only valid for
<code>push
</code> and
<code>save
</code> commands.
1014 <div class=
"paragraph"><p>All changes already added to the index are left intact.
</p></div>
1016 <dt class=
"hdlist1">
1019 <dt class=
"hdlist1">
1024 This option is only valid for
<code>push
</code> and
<code>save
</code> commands.
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
“Interactive Mode
” 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>
1036 <dt class=
"hdlist1">
1039 <dt class=
"hdlist1">
1044 This option is only valid for
<code>push
</code> and
<code>save
</code> commands.
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>
1051 <dt class=
"hdlist1">
1052 --pathspec-from-file=
<file
>
1056 This option is only valid for
<code>push
</code> command.
1058 <div class=
"paragraph"><p>Pathspec is passed in
<code><file
></code> instead of commandline args. If
1059 <code><file
></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>
1065 <dt class=
"hdlist1">
1070 This option is only valid for
<code>push
</code> command.
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>
1076 <dt class=
"hdlist1">
1079 <dt class=
"hdlist1">
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.
1087 <div class=
"paragraph"><p>Quiet, suppress feedback messages.
</p></div>
1089 <dt class=
"hdlist1">
1094 This option is only valid for
<code>push
</code> command.
1096 <div class=
"paragraph"><p>Separates pathspec from options for disambiguation purposes.
</p></div>
1098 <dt class=
"hdlist1">
1099 <pathspec
>…
1103 This option is only valid for
<code>push
</code> command.
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>
1111 <dt class=
"hdlist1">
1116 This option is only valid for
<code>apply
</code>,
<code>branch
</code>,
<code>drop
</code>,
<code>pop
</code>,
1117 <code>show
</code> commands.
1119 <div class=
"paragraph"><p>A reference of the form
<code>stash@{
<revision
>}
</code>. When no
<code><stash
></code> is
1120 given, the latest stash is assumed (that is,
<code>stash@{
0}
</code>).
</p></div>
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">
1137 -----H----I
</code></pre>
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
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
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.
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.
1169 $ git stash pop
</code></pre>
1172 <dt class=
"hdlist1">
1173 Interrupted workflow
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:
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"
1188 $ edit emergency fix
1189 $ git commit -a -m
"Fix in a hurry"
1191 $ git reset --soft HEAD^
1192 # ... continue hacking ...
</code></pre>
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 ...
1199 $ edit emergency fix
1200 $ git commit -a -m
"Fix in a hurry"
1202 # ... continue hacking ...
</code></pre>
1205 <dt class=
"hdlist1">
1206 Testing partial commits
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:
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>
1227 <dt class=
"hdlist1">
1228 Saving unrelated changes for future use
1232 When you are in the middle of massive changes and you find some
1233 unrelated issue that you don
’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.
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>
1249 <dt class=
"hdlist1">
1250 Recovering stash entries that were cleared/dropped erroneously
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:
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>
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
’s found there:
</p></div>
1275 <div class=
"dlist"><dl>
1276 <dt class=
"hdlist1">
1277 stash.showIncludeUntracked
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 the description of the
<em>show
</em> command in
<a href=
"git-stash.html">git-stash(
1)
</a>.
1286 <dt class=
"hdlist1">
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 the description of the
<em>show
</em> command in
<a href=
"git-stash.html">git-stash(
1)
</a>.
1296 <dt class=
"hdlist1">
1301 If this is set to true, the
<code>git stash show
</code> command without an
1302 option will show a diffstat of the stash entry. Defaults to true.
1303 See the description of the
<em>show
</em> command in
<a href=
"git-stash.html">git-stash(
1)
</a>.
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>
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>
1326 <div id=
"footnotes"><hr /></div>
1328 <div id=
"footer-text">
1330 2023-
06-
23 13:
24:
09 PDT