blob: de157b1ff2ef8892fbf72b21a08d7970200474b4 [file] [log] [blame]
Junio C Hamano1d90cb02007-07-03 07:05:311<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
2 "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
4<head>
5<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
Junio C Hamanoba4b9282008-07-06 05:20:316<meta name="generator" content="AsciiDoc 8.2.5" />
Junio C Hamano1d90cb02007-07-03 07:05:317<style type="text/css">
8/* Debug borders */
9p, li, dt, dd, div, pre, h1, h2, h3, h4, h5, h6 {
10/*
11 border: 1px solid red;
12*/
13}
14
15body {
16 margin: 1em 5% 1em 5%;
17}
18
Junio C Hamanoba4b9282008-07-06 05:20:3119a {
20 color: blue;
21 text-decoration: underline;
22}
23a:visited {
24 color: fuchsia;
25}
Junio C Hamano1d90cb02007-07-03 07:05:3126
27em {
28 font-style: italic;
29}
30
31strong {
32 font-weight: bold;
33}
34
35tt {
36 color: navy;
37}
38
39h1, h2, h3, h4, h5, h6 {
40 color: #527bbd;
41 font-family: sans-serif;
42 margin-top: 1.2em;
43 margin-bottom: 0.5em;
44 line-height: 1.3;
45}
46
Junio C Hamanoba4b9282008-07-06 05:20:3147h1, h2, h3 {
Junio C Hamano1d90cb02007-07-03 07:05:3148 border-bottom: 2px solid silver;
49}
50h2 {
Junio C Hamano1d90cb02007-07-03 07:05:3151 padding-top: 0.5em;
52}
Junio C Hamanoba4b9282008-07-06 05:20:3153h3 {
54 float: left;
55}
56h3 + * {
57 clear: left;
58}
Junio C Hamano1d90cb02007-07-03 07:05:3159
60div.sectionbody {
61 font-family: serif;
62 margin-left: 0;
63}
64
65hr {
66 border: 1px solid silver;
67}
68
69p {
70 margin-top: 0.5em;
71 margin-bottom: 0.5em;
72}
73
74pre {
75 padding: 0;
76 margin: 0;
77}
78
79span#author {
80 color: #527bbd;
81 font-family: sans-serif;
82 font-weight: bold;
Junio C Hamanoba4b9282008-07-06 05:20:3183 font-size: 1.1em;
Junio C Hamano1d90cb02007-07-03 07:05:3184}
85span#email {
86}
87span#revision {
88 font-family: sans-serif;
89}
90
91div#footer {
92 font-family: sans-serif;
93 font-size: small;
94 border-top: 2px solid silver;
95 padding-top: 0.5em;
96 margin-top: 4.0em;
97}
98div#footer-text {
99 float: left;
100 padding-bottom: 0.5em;
101}
102div#footer-badges {
103 float: right;
104 padding-bottom: 0.5em;
105}
106
107div#preamble,
108div.tableblock, div.imageblock, div.exampleblock, div.verseblock,
109div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock,
110div.admonitionblock {
111 margin-right: 10%;
112 margin-top: 1.5em;
113 margin-bottom: 1.5em;
114}
115div.admonitionblock {
116 margin-top: 2.5em;
117 margin-bottom: 2.5em;
118}
119
120div.content { /* Block element content. */
121 padding: 0;
122}
123
124/* Block element titles. */
125div.title, caption.title {
126 font-family: sans-serif;
127 font-weight: bold;
128 text-align: left;
129 margin-top: 1.0em;
130 margin-bottom: 0.5em;
131}
132div.title + * {
133 margin-top: 0;
134}
135
136td div.title:first-child {
137 margin-top: 0.0em;
138}
139div.content div.title:first-child {
140 margin-top: 0.0em;
141}
142div.content + div.title {
143 margin-top: 0.0em;
144}
145
146div.sidebarblock > div.content {
147 background: #ffffee;
148 border: 1px solid silver;
149 padding: 0.5em;
150}
151
Junio C Hamanoba4b9282008-07-06 05:20:31152div.listingblock {
153 margin-right: 0%;
154}
Junio C Hamano1d90cb02007-07-03 07:05:31155div.listingblock > div.content {
156 border: 1px solid silver;
157 background: #f4f4f4;
158 padding: 0.5em;
159}
160
161div.quoteblock > div.content {
162 padding-left: 2.0em;
163}
Junio C Hamanoba4b9282008-07-06 05:20:31164
165div.attribution {
Junio C Hamano1d90cb02007-07-03 07:05:31166 text-align: right;
167}
Junio C Hamanoba4b9282008-07-06 05:20:31168div.verseblock + div.attribution {
169 text-align: left;
170}
Junio C Hamano1d90cb02007-07-03 07:05:31171
172div.admonitionblock .icon {
173 vertical-align: top;
174 font-size: 1.1em;
175 font-weight: bold;
176 text-decoration: underline;
177 color: #527bbd;
178 padding-right: 0.5em;
179}
180div.admonitionblock td.content {
181 padding-left: 0.5em;
182 border-left: 2px solid silver;
183}
184
185div.exampleblock > div.content {
186 border-left: 2px solid silver;
187 padding: 0.5em;
188}
189
190div.verseblock div.content {
191 white-space: pre;
192}
193
194div.imageblock div.content { padding-left: 0; }
195div.imageblock img { border: 1px solid silver; }
196span.image img { border-style: none; }
197
198dl {
199 margin-top: 0.8em;
200 margin-bottom: 0.8em;
201}
202dt {
203 margin-top: 0.5em;
204 margin-bottom: 0;
205 font-style: italic;
206}
207dd > *:first-child {
208 margin-top: 0;
209}
210
211ul, ol {
212 list-style-position: outside;
213}
Junio C Hamanoba4b9282008-07-06 05:20:31214div.olist2 ol {
Junio C Hamano1d90cb02007-07-03 07:05:31215 list-style-type: lower-alpha;
216}
217
218div.tableblock > table {
Junio C Hamanoba4b9282008-07-06 05:20:31219 border: 3px solid #527bbd;
Junio C Hamano1d90cb02007-07-03 07:05:31220}
221thead {
222 font-family: sans-serif;
223 font-weight: bold;
224}
225tfoot {
226 font-weight: bold;
227}
228
229div.hlist {
230 margin-top: 0.8em;
231 margin-bottom: 0.8em;
232}
Junio C Hamanoba4b9282008-07-06 05:20:31233div.hlist td {
234 padding-bottom: 5px;
235}
Junio C Hamano1d90cb02007-07-03 07:05:31236td.hlist1 {
237 vertical-align: top;
238 font-style: italic;
239 padding-right: 0.8em;
240}
241td.hlist2 {
242 vertical-align: top;
243}
244
245@media print {
246 div#footer-badges { display: none; }
247}
Junio C Hamanoba4b9282008-07-06 05:20:31248
249div#toctitle {
250 color: #527bbd;
251 font-family: sans-serif;
252 font-size: 1.1em;
253 font-weight: bold;
254 margin-top: 1.0em;
255 margin-bottom: 0.1em;
256}
257
258div.toclevel1, div.toclevel2, div.toclevel3, div.toclevel4 {
259 margin-top: 0;
260 margin-bottom: 0;
261}
262div.toclevel2 {
263 margin-left: 2em;
264 font-size: 0.9em;
265}
266div.toclevel3 {
267 margin-left: 4em;
268 font-size: 0.9em;
269}
270div.toclevel4 {
271 margin-left: 6em;
272 font-size: 0.9em;
273}
274include1::./stylesheets/xhtml11-manpage.css[]
Junio C Hamano1d90cb02007-07-03 07:05:31275/* Workarounds for IE6's broken and incomplete CSS2. */
276
277div.sidebar-content {
278 background: #ffffee;
279 border: 1px solid silver;
280 padding: 0.5em;
281}
282div.sidebar-title, div.image-title {
283 font-family: sans-serif;
284 font-weight: bold;
285 margin-top: 0.0em;
286 margin-bottom: 0.5em;
287}
288
289div.listingblock div.content {
290 border: 1px solid silver;
291 background: #f4f4f4;
292 padding: 0.5em;
293}
294
295div.quoteblock-content {
296 padding-left: 2.0em;
297}
298
299div.exampleblock-content {
300 border-left: 2px solid silver;
301 padding-left: 0.5em;
302}
Junio C Hamanoba4b9282008-07-06 05:20:31303
304/* IE6 sets dynamically generated links as visited. */
305div#toc a:visited { color: blue; }
Junio C Hamano1d90cb02007-07-03 07:05:31306</style>
307<title>git-stash(1)</title>
308</head>
309<body>
310<div id="header">
311<h1>
312git-stash(1) Manual Page
313</h1>
314<h2>NAME</h2>
315<div class="sectionbody">
316<p>git-stash -
317 Stash the changes in a dirty working directory away
318</p>
319</div>
320</div>
321<h2>SYNOPSIS</h2>
322<div class="sectionbody">
323<div class="verseblock">
Junio C Hamano9e96a1a2008-08-16 10:23:18324<div class="content"><em>git stash</em> list [&lt;options&gt;]
Junio C Hamano2c14c8d2009-07-02 03:17:00325<em>git stash</em> show [&lt;stash&gt;]
326<em>git stash</em> drop [-q|--quiet] [&lt;stash&gt;]
327<em>git stash</em> ( pop | apply ) [--index] [-q|--quiet] [&lt;stash&gt;]
Junio C Hamano46a38aa2008-07-14 03:13:27328<em>git stash</em> branch &lt;branchname&gt; [&lt;stash&gt;]
Junio C Hamanoc28068f2009-09-08 00:55:23329<em>git stash</em> [save [--patch] [-k|--[no-]keep-index] [-q|--quiet] [&lt;message&gt;]]
Junio C Hamano9e96a1a2008-08-16 10:23:18330<em>git stash</em> clear
331<em>git stash</em> create</div></div>
Junio C Hamano1d90cb02007-07-03 07:05:31332</div>
Junio C Hamanoba4b9282008-07-06 05:20:31333<h2 id="_description">DESCRIPTION</h2>
Junio C Hamano1d90cb02007-07-03 07:05:31334<div class="sectionbody">
Junio C Hamanoba4b9282008-07-06 05:20:31335<div class="para"><p>Use <em>git stash</em> when you want to record the current state of the
Junio C Hamano1d90cb02007-07-03 07:05:31336working directory and the index, but want to go back to a clean
337working directory. The command saves your local modifications away
Junio C Hamanoba4b9282008-07-06 05:20:31338and reverts the working directory to match the <tt>HEAD</tt> commit.</p></div>
339<div class="para"><p>The modifications stashed away by this command can be listed with
Junio C Hamanofce7c7e2008-07-02 03:06:38340<tt>git stash list</tt>, inspected with <tt>git stash show</tt>, and restored
341(potentially on top of a different commit) with <tt>git stash apply</tt>.
342Calling <tt>git stash</tt> without any arguments is equivalent to <tt>git stash save</tt>.
343A stash is by default listed as "WIP on <em>branchname</em> &#8230;", but
Junio C Hamanobb6e0782007-07-19 02:14:50344you can give a more descriptive message on the command line when
Junio C Hamanoba4b9282008-07-06 05:20:31345you create one.</p></div>
346<div class="para"><p>The latest stash you created is stored in <tt>$GIT_DIR/refs/stash</tt>; older
Junio C Hamano1d90cb02007-07-03 07:05:31347stashes are found in the reflog of this reference and can be named using
Junio C Hamanob515b6a2007-08-08 09:21:16348the usual reflog syntax (e.g. <tt>stash@{0}</tt> is the most recently
349created stash, <tt>stash@{1}</tt> is the one before it, <tt>stash@{2.hours.ago}</tt>
Junio C Hamanoba4b9282008-07-06 05:20:31350is also possible).</p></div>
Junio C Hamano1d90cb02007-07-03 07:05:31351</div>
Junio C Hamanoba4b9282008-07-06 05:20:31352<h2 id="_options">OPTIONS</h2>
Junio C Hamano1d90cb02007-07-03 07:05:31353<div class="sectionbody">
Junio C Hamanoba4b9282008-07-06 05:20:31354<div class="vlist"><dl>
Junio C Hamano1d90cb02007-07-03 07:05:31355<dt>
Junio C Hamanoc28068f2009-09-08 00:55:23356save [--patch] [--[no-]keep-index] [-q|--quiet] [&lt;message&gt;]
Junio C Hamano1d90cb02007-07-03 07:05:31357</dt>
358<dd>
359<p>
Junio C Hamanofce7c7e2008-07-02 03:06:38360 Save your local modifications to a new <em>stash</em>, and run <tt>git reset
Junio C Hamanoc28068f2009-09-08 00:55:23361 --hard</tt> to revert them. The &lt;message&gt; part is optional and gives
362 the description along with the stashed state. For quickly making
363 a snapshot, you can omit _both_ "save" and &lt;message&gt;, but giving
364 only &lt;message&gt; does not trigger this action to prevent a misspelled
365 subcommand from making an unwanted stash.
Junio C Hamano1d90cb02007-07-03 07:05:31366</p>
Junio C Hamano46a38aa2008-07-14 03:13:27367<div class="para"><p>If the <tt>--keep-index</tt> option is used, all changes already added to the
368index are left intact.</p></div>
Junio C Hamanoc28068f2009-09-08 00:55:23369<div class="para"><p>With <tt>--patch</tt>, you can interactively select hunks from in the diff
370between HEAD and the working tree to be stashed. The stash entry is
371constructed such that its index state is the same as the index state
372of your repository, and its worktree contains only the changes you
373selected interactively. The selected changes are then rolled back
374from your worktree.</p></div>
375<div class="para"><p>The <tt>--patch</tt> option implies <tt>--keep-index</tt>. You can use
376<tt>--no-keep-index</tt> to override this.</p></div>
Junio C Hamano1d90cb02007-07-03 07:05:31377</dd>
378<dt>
Junio C Hamano83d46a22008-02-21 02:29:42379list [&lt;options&gt;]
Junio C Hamano1d90cb02007-07-03 07:05:31380</dt>
381<dd>
382<p>
383 List the stashes that you currently have. Each <em>stash</em> is listed
Junio C Hamanob515b6a2007-08-08 09:21:16384 with its name (e.g. <tt>stash@{0}</tt> is the latest stash, <tt>stash@{1}</tt> is
Junio C Hamano1d90cb02007-07-03 07:05:31385 the one before, etc.), the name of the branch that was current when the
386 stash was made, and a short description of the commit the stash was
387 based on.
388</p>
389<div class="listingblock">
390<div class="content">
Junio C Hamanobb6e0782007-07-19 02:14:50391<pre><tt>stash@{0}: WIP on submit: 6ebd0e2... Update git-stash documentation
392stash@{1}: On master: 9cc0589... Add git-stash</tt></pre>
Junio C Hamano1d90cb02007-07-03 07:05:31393</div></div>
Junio C Hamanoba4b9282008-07-06 05:20:31394<div class="para"><p>The command takes options applicable to the <em>git-log</em>
395command to control what is shown and how. See <a href="git-log.html">git-log(1)</a>.</p></div>
Junio C Hamano1d90cb02007-07-03 07:05:31396</dd>
397<dt>
398show [&lt;stash&gt;]
399</dt>
400<dd>
401<p>
Junio C Hamano764a6672007-10-23 01:23:31402 Show the changes recorded in the stash as a diff between the
Junio C Hamano1d90cb02007-07-03 07:05:31403 stashed state and its original parent. When no <tt>&lt;stash&gt;</tt> is given,
404 shows the latest one. By default, the command shows the diffstat, but
Junio C Hamanoba4b9282008-07-06 05:20:31405 it will accept any format known to <em>git-diff</em> (e.g., <tt>git stash show
Junio C Hamanob515b6a2007-08-08 09:21:16406 -p stash@{1}</tt> to view the second most recent stash in patch form).
Junio C Hamano1d90cb02007-07-03 07:05:31407</p>
408</dd>
409<dt>
Junio C Hamano2c14c8d2009-07-02 03:17:00410pop [--index] [-q|--quiet] [&lt;stash&gt;]
Junio C Hamano7d3275e2009-05-31 21:53:30411</dt>
412<dd>
413<p>
414 Remove a single stashed state from the stash list and apply it
415 on top of the current working tree state, i.e., do the inverse
416 operation of <tt>git stash save</tt>. The working directory must
417 match the index.
418</p>
419<div class="para"><p>Applying the state can fail with conflicts; in this case, it is not
420removed from the stash list. You need to resolve the conflicts by hand
421and call <tt>git stash drop</tt> manually afterwards.</p></div>
Junio C Hamanof068d542009-06-09 15:46:41422<div class="para"><p>If the <tt>--index</tt> option is used, then tries to reinstate not only the working
423tree's changes, but also the index's ones. However, this can fail, when you
424have conflicts (which are stored in the index, where you therefore can no
425longer apply the changes as they were originally).</p></div>
426<div class="para"><p>When no <tt>&lt;stash&gt;</tt> is given, <tt>stash@{0}</tt> is assumed.</p></div>
Junio C Hamano7d3275e2009-05-31 21:53:30427</dd>
428<dt>
Junio C Hamano2c14c8d2009-07-02 03:17:00429apply [--index] [-q|--quiet] [&lt;stash&gt;]
Junio C Hamano1d90cb02007-07-03 07:05:31430</dt>
431<dd>
432<p>
Junio C Hamano7d3275e2009-05-31 21:53:30433 Like <tt>pop</tt>, but do not remove the state from the stash list.
Junio C Hamano1d90cb02007-07-03 07:05:31434</p>
Junio C Hamano1d90cb02007-07-03 07:05:31435</dd>
436<dt>
Junio C Hamano46a38aa2008-07-14 03:13:27437branch &lt;branchname&gt; [&lt;stash&gt;]
438</dt>
439<dd>
440<p>
441 Creates and checks out a new branch named <tt>&lt;branchname&gt;</tt> starting from
442 the commit at which the <tt>&lt;stash&gt;</tt> was originally created, applies the
443 changes recorded in <tt>&lt;stash&gt;</tt> to the new working tree and index, then
444 drops the <tt>&lt;stash&gt;</tt> if that completes successfully. When no <tt>&lt;stash&gt;</tt>
445 is given, applies the latest one.
446</p>
447<div class="para"><p>This is useful if the branch on which you ran <tt>git stash save</tt> has
448changed enough that <tt>git stash apply</tt> fails due to conflicts. Since
449the stash is applied on top of the commit that was HEAD at the time
450<tt>git stash</tt> was run, it restores the originally stashed state with
451no conflicts.</p></div>
452</dd>
453<dt>
Junio C Hamano1d90cb02007-07-03 07:05:31454clear
455</dt>
456<dd>
457<p>
458 Remove all the stashed states. Note that those states will then
Junio C Hamano9f883862009-08-11 06:23:52459 be subject to pruning, and may be impossible to recover (see
460 <em>Examples</em> below for a possible strategy).
Junio C Hamano1d90cb02007-07-03 07:05:31461</p>
462</dd>
Junio C Hamano86bcccc2008-03-08 09:33:55463<dt>
Junio C Hamano2c14c8d2009-07-02 03:17:00464drop [-q|--quiet] [&lt;stash&gt;]
Junio C Hamano86bcccc2008-03-08 09:33:55465</dt>
466<dd>
467<p>
468 Remove a single stashed state from the stash list. When no <tt>&lt;stash&gt;</tt>
469 is given, it removes the latest one. i.e. <tt>stash@{0}</tt>
470</p>
471</dd>
472<dt>
Junio C Hamano9e96a1a2008-08-16 10:23:18473create
474</dt>
475<dd>
476<p>
477 Create a stash (which is a regular commit object) and return its
478 object name, without storing it anywhere in the ref namespace.
479</p>
480</dd>
Junio C Hamanoba4b9282008-07-06 05:20:31481</dl></div>
Junio C Hamano1d90cb02007-07-03 07:05:31482</div>
Junio C Hamanoba4b9282008-07-06 05:20:31483<h2 id="_discussion">DISCUSSION</h2>
Junio C Hamano1d90cb02007-07-03 07:05:31484<div class="sectionbody">
Junio C Hamanoba4b9282008-07-06 05:20:31485<div class="para"><p>A stash is represented as a commit whose tree records the state of the
Junio C Hamano1d90cb02007-07-03 07:05:31486working directory, and its first parent is the commit at <tt>HEAD</tt> when
487the stash was created. The tree of the second parent records the
488state of the index when the stash is made, and it is made a child of
Junio C Hamanoba4b9282008-07-06 05:20:31489the <tt>HEAD</tt> commit. The ancestry graph looks like this:</p></div>
Junio C Hamano1d90cb02007-07-03 07:05:31490<div class="literalblock">
491<div class="content">
492<pre><tt> .----W
493 / /
Junio C Hamano28d8ede2007-07-05 05:51:38494-----H----I</tt></pre>
Junio C Hamano1d90cb02007-07-03 07:05:31495</div></div>
Junio C Hamanoba4b9282008-07-06 05:20:31496<div class="para"><p>where <tt>H</tt> is the <tt>HEAD</tt> commit, <tt>I</tt> is a commit that records the state
Junio C Hamano1d90cb02007-07-03 07:05:31497of the index, and <tt>W</tt> is a commit that records the state of the working
Junio C Hamanoba4b9282008-07-06 05:20:31498tree.</p></div>
Junio C Hamano1d90cb02007-07-03 07:05:31499</div>
Junio C Hamanoba4b9282008-07-06 05:20:31500<h2 id="_examples">EXAMPLES</h2>
Junio C Hamano1d90cb02007-07-03 07:05:31501<div class="sectionbody">
Junio C Hamanoba4b9282008-07-06 05:20:31502<div class="vlist"><dl>
Junio C Hamano1d90cb02007-07-03 07:05:31503<dt>
504Pulling into a dirty tree
505</dt>
506<dd>
507<p>
508When you are in the middle of something, you learn that there are
509upstream changes that are possibly relevant to what you are
510doing. When your local changes do not conflict with the changes in
511the upstream, a simple <tt>git pull</tt> will let you move forward.
512</p>
Junio C Hamanoba4b9282008-07-06 05:20:31513<div class="para"><p>However, there are cases in which your local changes do conflict with
Junio C Hamano1d90cb02007-07-03 07:05:31514the upstream changes, and <tt>git pull</tt> refuses to overwrite your
515changes. In such a case, you can stash your changes away,
Junio C Hamanoba4b9282008-07-06 05:20:31516perform a pull, and then unstash, like this:</p></div>
Junio C Hamano1d90cb02007-07-03 07:05:31517<div class="listingblock">
518<div class="content">
519<pre><tt>$ git pull
Junio C Hamanoa2f46622008-09-03 05:20:31520 ...
Junio C Hamano1d90cb02007-07-03 07:05:31521file foobar not up to date, cannot merge.
522$ git stash
523$ git pull
Junio C Hamano7d3275e2009-05-31 21:53:30524$ git stash pop</tt></pre>
Junio C Hamano1d90cb02007-07-03 07:05:31525</div></div>
526</dd>
527<dt>
528Interrupted workflow
529</dt>
530<dd>
531<p>
532When you are in the middle of something, your boss comes in and
533demands that you fix something immediately. Traditionally, you would
534make a commit to a temporary branch to store your changes away, and
535return to your original branch to make the emergency fix, like this:
536</p>
537<div class="listingblock">
538<div class="content">
Junio C Hamanoa2f46622008-09-03 05:20:31539<pre><tt># ... hack hack hack ...
Junio C Hamano1d90cb02007-07-03 07:05:31540$ git checkout -b my_wip
541$ git commit -a -m "WIP"
542$ git checkout master
543$ edit emergency fix
544$ git commit -a -m "Fix in a hurry"
545$ git checkout my_wip
546$ git reset --soft HEAD^
Junio C Hamanoa2f46622008-09-03 05:20:31547# ... continue hacking ...</tt></pre>
Junio C Hamano1d90cb02007-07-03 07:05:31548</div></div>
Junio C Hamanoba4b9282008-07-06 05:20:31549<div class="para"><p>You can use <em>git-stash</em> to simplify the above, like this:</p></div>
Junio C Hamano1d90cb02007-07-03 07:05:31550<div class="listingblock">
551<div class="content">
Junio C Hamanoa2f46622008-09-03 05:20:31552<pre><tt># ... hack hack hack ...
Junio C Hamano1d90cb02007-07-03 07:05:31553$ git stash
554$ edit emergency fix
555$ git commit -a -m "Fix in a hurry"
Junio C Hamano7d3275e2009-05-31 21:53:30556$ git stash pop
Junio C Hamanoa2f46622008-09-03 05:20:31557# ... continue hacking ...</tt></pre>
Junio C Hamano1d90cb02007-07-03 07:05:31558</div></div>
559</dd>
Junio C Hamano46a38aa2008-07-14 03:13:27560<dt>
561Testing partial commits
562</dt>
563<dd>
564<p>
565You can use <tt>git stash save --keep-index</tt> when you want to make two or
566more commits out of the changes in the work tree, and you want to test
567each change before committing:
568</p>
569<div class="listingblock">
570<div class="content">
Junio C Hamanoa2f46622008-09-03 05:20:31571<pre><tt># ... hack hack hack ...
Junio C Hamano46a38aa2008-07-14 03:13:27572$ git add --patch foo # add just first part to the index
573$ git stash save --keep-index # save all other changes to the stash
574$ edit/build/test first part
Junio C Hamanoa2f46622008-09-03 05:20:31575$ git commit -m 'First part' # commit fully tested change
Junio C Hamano46a38aa2008-07-14 03:13:27576$ git stash pop # prepare to work on all other changes
Junio C Hamanoa2f46622008-09-03 05:20:31577# ... repeat above five steps until one commit remains ...
Junio C Hamano46a38aa2008-07-14 03:13:27578$ edit/build/test remaining parts
579$ git commit foo -m 'Remaining parts'</tt></pre>
580</div></div>
581</dd>
Junio C Hamano9f883862009-08-11 06:23:52582<dt>
583Recovering stashes that were cleared/dropped erroneously
584</dt>
585<dd>
586<p>
587If you mistakenly drop or clear stashes, they cannot be recovered
588through the normal safety mechanisms. However, you can try the
589following incantation to get a list of stashes that are still in your
590repository, but not reachable any more:
591</p>
592<div class="listingblock">
593<div class="content">
594<pre><tt>git fsck --unreachable |
595grep commit | cut -d\ -f3 |
596xargs git log --merges --no-walk --grep=WIP</tt></pre>
597</div></div>
598</dd>
Junio C Hamanoba4b9282008-07-06 05:20:31599</dl></div>
Junio C Hamano1d90cb02007-07-03 07:05:31600</div>
Junio C Hamanoba4b9282008-07-06 05:20:31601<h2 id="_see_also">SEE ALSO</h2>
Junio C Hamano1d90cb02007-07-03 07:05:31602<div class="sectionbody">
Junio C Hamanoba4b9282008-07-06 05:20:31603<div class="para"><p><a href="git-checkout.html">git-checkout(1)</a>,
Junio C Hamano1d90cb02007-07-03 07:05:31604<a href="git-commit.html">git-commit(1)</a>,
605<a href="git-reflog.html">git-reflog(1)</a>,
Junio C Hamanoba4b9282008-07-06 05:20:31606<a href="git-reset.html">git-reset(1)</a></p></div>
Junio C Hamano1d90cb02007-07-03 07:05:31607</div>
Junio C Hamanoba4b9282008-07-06 05:20:31608<h2 id="_author">AUTHOR</h2>
Junio C Hamano1d90cb02007-07-03 07:05:31609<div class="sectionbody">
Junio C Hamanoba4b9282008-07-06 05:20:31610<div class="para"><p>Written by Nanako Shiraishi &lt;nanako3@bluebottle.com&gt;</p></div>
Junio C Hamano1d90cb02007-07-03 07:05:31611</div>
Junio C Hamanoba4b9282008-07-06 05:20:31612<h2 id="_git">GIT</h2>
Junio C Hamano1d90cb02007-07-03 07:05:31613<div class="sectionbody">
Junio C Hamanoba4b9282008-07-06 05:20:31614<div class="para"><p>Part of the <a href="git.html">git(1)</a> suite</p></div>
Junio C Hamano1d90cb02007-07-03 07:05:31615</div>
616<div id="footer">
617<div id="footer-text">
Junio C Hamanoc28068f2009-09-08 00:55:23618Last updated 2009-09-08 00:55:01 UTC
Junio C Hamano1d90cb02007-07-03 07:05:31619</div>
620</div>
621</body>
622</html>