blob: 0eeee7bc0daf06e7ae14ee81521a9deafb9a0ccf [file] [log] [blame]
Junio C Hamano1a4e8412005-12-27 08:17:231<!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 Hamano1a4e8412005-12-27 08:17:237<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 Hamano1a4e8412005-12-27 08:17:2326
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 Hamano1a4e8412005-12-27 08:17:2348 border-bottom: 2px solid silver;
49}
50h2 {
Junio C Hamano1a4e8412005-12-27 08:17:2351 padding-top: 0.5em;
52}
Junio C Hamanoba4b9282008-07-06 05:20:3153h3 {
54 float: left;
55}
56h3 + * {
57 clear: left;
58}
Junio C Hamano1a4e8412005-12-27 08:17:2359
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 Hamano1a4e8412005-12-27 08:17:2384}
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 Hamano1a4e8412005-12-27 08:17:23155div.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 Hamano1a4e8412005-12-27 08:17:23166 text-align: right;
167}
Junio C Hamanoba4b9282008-07-06 05:20:31168div.verseblock + div.attribution {
169 text-align: left;
170}
Junio C Hamano1a4e8412005-12-27 08:17:23171
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 Hamano1a4e8412005-12-27 08:17:23215 list-style-type: lower-alpha;
216}
217
218div.tableblock > table {
Junio C Hamanoba4b9282008-07-06 05:20:31219 border: 3px solid #527bbd;
Junio C Hamano1a4e8412005-12-27 08:17:23220}
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 Hamano1a4e8412005-12-27 08:17:23236td.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 Hamano1a4e8412005-12-27 08:17:23275/* 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 Hamano1a4e8412005-12-27 08:17:23306</style>
307<title>git-reset(1)</title>
308</head>
309<body>
310<div id="header">
311<h1>
312git-reset(1) Manual Page
313</h1>
314<h2>NAME</h2>
315<div class="sectionbody">
316<p>git-reset -
Junio C Hamano01078922006-03-10 00:31:47317 Reset current HEAD to the specified state
Junio C Hamano1a4e8412005-12-27 08:17:23318</p>
319</div>
320</div>
321<h2>SYNOPSIS</h2>
322<div class="sectionbody">
Junio C Hamanod793de52006-12-26 09:11:43323<div class="verseblock">
Junio C Hamanobbbb8652008-12-29 10:34:22324<div class="content"><em>git reset</em> [--mixed | --soft | --hard | --merge] [-q] [&lt;commit&gt;]
Junio C Hamanoc28068f2009-09-08 00:55:23325<em>git reset</em> [-q] [&lt;commit&gt;] [--] &lt;paths&gt;&#8230;
326<em>git reset</em> --patch [&lt;commit&gt;] [--] [&lt;paths&gt;&#8230;]</div></div>
Junio C Hamano1a4e8412005-12-27 08:17:23327</div>
Junio C Hamanoba4b9282008-07-06 05:20:31328<h2 id="_description">DESCRIPTION</h2>
Junio C Hamano1a4e8412005-12-27 08:17:23329<div class="sectionbody">
Junio C Hamanoba4b9282008-07-06 05:20:31330<div class="para"><p>Sets the current head to the specified commit and optionally resets the
331index and working tree to match.</p></div>
332<div class="para"><p>This command is useful if you notice some small error in a recent
Junio C Hamano1a4e8412005-12-27 08:17:23333commit (or set of commits) and want to redo that part without showing
Junio C Hamanoba4b9282008-07-06 05:20:31334the undo in the history.</p></div>
335<div class="para"><p>If you want to undo a commit other than the latest on a branch,
336<a href="git-revert.html">git-revert(1)</a> is your friend.</p></div>
Junio C Hamanoc28068f2009-09-08 00:55:23337<div class="para"><p>The second and third forms with <em>paths</em> and/or --patch are used to
338revert selected paths in the index from a given commit, without moving
339HEAD.</p></div>
Junio C Hamano1a4e8412005-12-27 08:17:23340</div>
Junio C Hamanoba4b9282008-07-06 05:20:31341<h2 id="_options">OPTIONS</h2>
Junio C Hamano1a4e8412005-12-27 08:17:23342<div class="sectionbody">
Junio C Hamanoba4b9282008-07-06 05:20:31343<div class="vlist"><dl>
Junio C Hamano1a4e8412005-12-27 08:17:23344<dt>
345--mixed
346</dt>
347<dd>
348<p>
Junio C Hamano341071d2006-06-04 07:24:48349 Resets the index but not the working tree (i.e., the changed files
Junio C Hamano1a4e8412005-12-27 08:17:23350 are preserved but not marked for commit) and reports what has not
351 been updated. This is the default action.
352</p>
353</dd>
354<dt>
355--soft
356</dt>
357<dd>
358<p>
359 Does not touch the index file nor the working tree at all, but
360 requires them to be in a good order. This leaves all your changed
Junio C Hamanoba4b9282008-07-06 05:20:31361 files "Changes to be committed", as <em>git-status</em> would
Junio C Hamano1a4e8412005-12-27 08:17:23362 put it.
363</p>
364</dd>
365<dt>
366--hard
367</dt>
368<dd>
369<p>
370 Matches the working tree and index to that of the tree being
371 switched to. Any changes to tracked files in the working tree
Junio C Hamanod793de52006-12-26 09:11:43372 since &lt;commit&gt; are lost.
Junio C Hamano1a4e8412005-12-27 08:17:23373</p>
374</dd>
375<dt>
Junio C Hamanobbbb8652008-12-29 10:34:22376--merge
377</dt>
378<dd>
379<p>
380 Resets the index to match the tree recorded by the named commit,
381 and updates the files that are different between the named commit
382 and the current commit in the working tree.
383</p>
384</dd>
385<dt>
Junio C Hamanoc28068f2009-09-08 00:55:23386-p
387</dt>
388<dt>
389--patch
390</dt>
391<dd>
392<p>
393 Interactively select hunks in the difference between the index
394 and &lt;commit&gt; (defaults to HEAD). The chosen hunks are applied
395 in reverse to the index.
396</p>
397<div class="para"><p>This means that <tt>git reset -p</tt> is the opposite of <tt>git add -p</tt> (see
398<a href="git-add.html">git-add(1)</a>).</p></div>
399</dd>
400<dt>
Junio C Hamano422cfec2007-11-08 08:07:45401-q
402</dt>
Junio C Hamanob141a922010-01-10 19:55:14403<dt>
404--quiet
405</dt>
Junio C Hamano422cfec2007-11-08 08:07:45406<dd>
407<p>
408 Be quiet, only report errors.
409</p>
410</dd>
411<dt>
Junio C Hamanod793de52006-12-26 09:11:43412&lt;commit&gt;
Junio C Hamano1a4e8412005-12-27 08:17:23413</dt>
414<dd>
415<p>
Junio C Hamano14b76482008-01-05 10:32:26416 Commit to make the current HEAD. If not given defaults to HEAD.
Junio C Hamano1a4e8412005-12-27 08:17:23417</p>
418</dd>
Junio C Hamanoba4b9282008-07-06 05:20:31419</dl></div>
Junio C Hamano1bb569e2006-05-05 23:14:25420</div>
Junio C Hamanoba4b9282008-07-06 05:20:31421<h2 id="_examples">Examples</h2>
Junio C Hamano1bb569e2006-05-05 23:14:25422<div class="sectionbody">
Junio C Hamanoba4b9282008-07-06 05:20:31423<div class="vlist"><dl>
Junio C Hamano1a4e8412005-12-27 08:17:23424<dt>
425Undo a commit and redo
426</dt>
427<dd>
428<div class="listingblock">
429<div class="content">
430<pre><tt>$ git commit ...
Junio C Hamanoc8d88c22006-04-29 07:02:01431$ git reset --soft HEAD^ <b>(1)</b>
432$ edit <b>(2)</b>
433$ git commit -a -c ORIG_HEAD <b>(3)</b></tt></pre>
434</div></div>
Junio C Hamanoba4b9282008-07-06 05:20:31435<div class="colist"><ol>
Junio C Hamanoc8d88c22006-04-29 07:02:01436<li>
437<p>
438This is most often done when you remembered what you
Junio C Hamano1a4e8412005-12-27 08:17:23439just committed is incomplete, or you misspelled your commit
440message, or both. Leaves working tree as it was before "reset".
Junio C Hamanoc8d88c22006-04-29 07:02:01441</p>
442</li>
443<li>
444<p>
Junio C Hamano092f5f02007-08-02 07:23:38445Make corrections to working tree files.
Junio C Hamanoc8d88c22006-04-29 07:02:01446</p>
447</li>
448<li>
449<p>
450"reset" copies the old head to .git/ORIG_HEAD; redo the
Junio C Hamano1a4e8412005-12-27 08:17:23451commit by starting with its log message. If you do not need to
Junio C Hamanoc8d88c22006-04-29 07:02:01452edit the message further, you can give -C option instead.
453</p>
Junio C Hamanoba4b9282008-07-06 05:20:31454<div class="para"><p>See also the --amend option to <a href="git-commit.html">git-commit(1)</a>.</p></div>
Junio C Hamanoc8d88c22006-04-29 07:02:01455</li>
Junio C Hamanoba4b9282008-07-06 05:20:31456</ol></div>
Junio C Hamano1a4e8412005-12-27 08:17:23457</dd>
458<dt>
459Undo commits permanently
460</dt>
461<dd>
462<div class="listingblock">
463<div class="content">
464<pre><tt>$ git commit ...
Junio C Hamanoc8d88c22006-04-29 07:02:01465$ git reset --hard HEAD~3 <b>(1)</b></tt></pre>
Junio C Hamano1a4e8412005-12-27 08:17:23466</div></div>
Junio C Hamanoba4b9282008-07-06 05:20:31467<div class="colist"><ol>
Junio C Hamanoc8d88c22006-04-29 07:02:01468<li>
469<p>
470The last three commits (HEAD, HEAD^, and HEAD~2) were bad
471and you do not want to ever see them again. Do <strong>not</strong> do this if
Junio C Hamano7d06a8a2008-10-20 05:42:33472you have already given these commits to somebody else. (See the
473"RECOVERING FROM UPSTREAM REBASE" section in <a href="git-rebase.html">git-rebase(1)</a> for
474the implications of doing so.)
Junio C Hamanoc8d88c22006-04-29 07:02:01475</p>
476</li>
Junio C Hamanoba4b9282008-07-06 05:20:31477</ol></div>
Junio C Hamano1a4e8412005-12-27 08:17:23478</dd>
479<dt>
480Undo a commit, making it a topic branch
481</dt>
482<dd>
483<div class="listingblock">
484<div class="content">
Junio C Hamanoc8d88c22006-04-29 07:02:01485<pre><tt>$ git branch topic/wip <b>(1)</b>
486$ git reset --hard HEAD~3 <b>(2)</b>
487$ git checkout topic/wip <b>(3)</b></tt></pre>
488</div></div>
Junio C Hamanoba4b9282008-07-06 05:20:31489<div class="colist"><ol>
Junio C Hamanoc8d88c22006-04-29 07:02:01490<li>
491<p>
492You have made some commits, but realize they were premature
Junio C Hamano1a4e8412005-12-27 08:17:23493to be in the "master" branch. You want to continue polishing
494them in a topic branch, so create "topic/wip" branch off of the
495current HEAD.
Junio C Hamanoc8d88c22006-04-29 07:02:01496</p>
497</li>
498<li>
499<p>
500Rewind the master branch to get rid of those three commits.
501</p>
502</li>
503<li>
504<p>
505Switch to "topic/wip" branch and keep working.
506</p>
507</li>
Junio C Hamanoba4b9282008-07-06 05:20:31508</ol></div>
Junio C Hamano1a4e8412005-12-27 08:17:23509</dd>
510<dt>
Junio C Hamano89d4e0f2007-02-18 00:34:59511Undo add
Junio C Hamano1a4e8412005-12-27 08:17:23512</dt>
513<dd>
514<div class="listingblock">
515<div class="content">
Junio C Hamanoc8d88c22006-04-29 07:02:01516<pre><tt>$ edit <b>(1)</b>
Junio C Hamano89d4e0f2007-02-18 00:34:59517$ git add frotz.c filfre.c
Junio C Hamanoc8d88c22006-04-29 07:02:01518$ mailx <b>(2)</b>
519$ git reset <b>(3)</b>
520$ git pull git://info.example.com/ nitfol <b>(4)</b></tt></pre>
521</div></div>
Junio C Hamanoba4b9282008-07-06 05:20:31522<div class="colist"><ol>
Junio C Hamanoc8d88c22006-04-29 07:02:01523<li>
524<p>
Junio C Hamano092f5f02007-08-02 07:23:38525You are happily working on something, and find the changes
Junio C Hamano1a4e8412005-12-27 08:17:23526in these files are in good order. You do not want to see them
527when you run "git diff", because you plan to work on other files
528and changes with these files are distracting.
Junio C Hamanoc8d88c22006-04-29 07:02:01529</p>
530</li>
531<li>
532<p>
Junio C Hamano092f5f02007-08-02 07:23:38533Somebody asks you to pull, and the changes sounds worthy of merging.
Junio C Hamanoc8d88c22006-04-29 07:02:01534</p>
535</li>
536<li>
537<p>
Junio C Hamano092f5f02007-08-02 07:23:38538However, you already dirtied the index (i.e. your index does
Junio C Hamano1a4e8412005-12-27 08:17:23539not match the HEAD commit). But you know the pull you are going
540to make does not affect frotz.c nor filfre.c, so you revert the
541index changes for these two files. Your changes in working tree
542remain there.
Junio C Hamanoc8d88c22006-04-29 07:02:01543</p>
544</li>
545<li>
546<p>
Junio C Hamano092f5f02007-08-02 07:23:38547Then you can pull and merge, leaving frotz.c and filfre.c
Junio C Hamanoc8d88c22006-04-29 07:02:01548changes still in the working tree.
549</p>
550</li>
Junio C Hamanoba4b9282008-07-06 05:20:31551</ol></div>
Junio C Hamano1a4e8412005-12-27 08:17:23552</dd>
553<dt>
554Undo a merge or pull
555</dt>
556<dd>
557<div class="listingblock">
558<div class="content">
Junio C Hamanoc8d88c22006-04-29 07:02:01559<pre><tt>$ git pull <b>(1)</b>
Junio C Hamano1a4e8412005-12-27 08:17:23560Auto-merging nitfol
561CONFLICT (content): Merge conflict in nitfol
Junio C Hamano6a3c8272008-12-19 21:38:18562Automatic merge failed; fix conflicts and then commit the result.
Junio C Hamanoc8d88c22006-04-29 07:02:01563$ git reset --hard <b>(2)</b>
564$ git pull . topic/branch <b>(3)</b>
Junio C Hamano1a4e8412005-12-27 08:17:23565Updating from 41223... to 13134...
Junio C Hamano3f680f32009-11-16 02:10:54566Fast-forward
Junio C Hamanoc8d88c22006-04-29 07:02:01567$ git reset --hard ORIG_HEAD <b>(4)</b></tt></pre>
568</div></div>
Junio C Hamanoba4b9282008-07-06 05:20:31569<div class="colist"><ol>
Junio C Hamanoc8d88c22006-04-29 07:02:01570<li>
571<p>
Junio C Hamano092f5f02007-08-02 07:23:38572Try to update from the upstream resulted in a lot of
Junio C Hamanoc8d88c22006-04-29 07:02:01573conflicts; you were not ready to spend a lot of time merging
574right now, so you decide to do that later.
575</p>
576</li>
577<li>
578<p>
579"pull" has not made merge commit, so "git reset --hard"
580which is a synonym for "git reset --hard HEAD" clears the mess
581from the index file and the working tree.
582</p>
583</li>
584<li>
585<p>
Junio C Hamano092f5f02007-08-02 07:23:38586Merge a topic branch into the current branch, which resulted
Junio C Hamano3f680f32009-11-16 02:10:54587in a fast-forward.
Junio C Hamanoc8d88c22006-04-29 07:02:01588</p>
589</li>
590<li>
591<p>
Junio C Hamano092f5f02007-08-02 07:23:38592But you decided that the topic branch is not ready for public
Junio C Hamano1a4e8412005-12-27 08:17:23593consumption yet. "pull" or "merge" always leaves the original
594tip of the current branch in ORIG_HEAD, so resetting hard to it
595brings your index file and the working tree back to that state,
Junio C Hamanoc8d88c22006-04-29 07:02:01596and resets the tip of the branch to that commit.
597</p>
598</li>
Junio C Hamanoba4b9282008-07-06 05:20:31599</ol></div>
Junio C Hamano1a4e8412005-12-27 08:17:23600</dd>
Junio C Hamano74e8a2d2006-01-14 03:58:41601<dt>
Junio C Hamanobbbb8652008-12-29 10:34:22602Undo a merge or pull inside a dirty work tree
603</dt>
604<dd>
605<div class="listingblock">
606<div class="content">
607<pre><tt>$ git pull <b>(1)</b>
608Auto-merging nitfol
609Merge made by recursive.
610 nitfol | 20 +++++----
611 ...
612$ git reset --merge ORIG_HEAD <b>(2)</b></tt></pre>
613</div></div>
614<div class="colist"><ol>
615<li>
616<p>
617Even if you may have local modifications in your
618working tree, you can safely say "git pull" when you know
619that the change in the other branch does not overlap with
620them.
621</p>
622</li>
623<li>
624<p>
625After inspecting the result of the merge, you may find
626that the change in the other branch is unsatisfactory. Running
627"git reset --hard ORIG_HEAD" will let you go back to where you
628were, but it will discard your local changes, which you do not
629want. "git reset --merge" keeps your local changes.
630</p>
631</li>
632</ol></div>
633</dd>
634<dt>
Junio C Hamano74e8a2d2006-01-14 03:58:41635Interrupted workflow
636</dt>
637<dd>
Junio C Hamanoba4b9282008-07-06 05:20:31638<div class="para"><p>Suppose you are interrupted by an urgent fix request while you
Junio C Hamanoa6331a82006-01-22 07:50:33639are in the middle of a large change. The files in your
Junio C Hamano74e8a2d2006-01-14 03:58:41640working tree are not in any shape to be committed yet, but you
Junio C Hamanoba4b9282008-07-06 05:20:31641need to get to the other branch for a quick bugfix.</p></div>
Junio C Hamano74e8a2d2006-01-14 03:58:41642<div class="listingblock">
643<div class="content">
644<pre><tt>$ git checkout feature ;# you were working in "feature" branch and
645$ work work work ;# got interrupted
Junio C Hamano7ae0ab22007-11-03 02:46:46646$ git commit -a -m "snapshot WIP" <b>(1)</b>
Junio C Hamano74e8a2d2006-01-14 03:58:41647$ git checkout master
648$ fix fix fix
649$ git commit ;# commit with real log
650$ git checkout feature
Junio C Hamanoc8d88c22006-04-29 07:02:01651$ git reset --soft HEAD^ ;# go back to WIP state <b>(2)</b>
652$ git reset <b>(3)</b></tt></pre>
Junio C Hamano74e8a2d2006-01-14 03:58:41653</div></div>
Junio C Hamanoba4b9282008-07-06 05:20:31654<div class="colist"><ol>
Junio C Hamanoc8d88c22006-04-29 07:02:01655<li>
656<p>
657This commit will get blown away so a throw-away log message is OK.
658</p>
659</li>
660<li>
661<p>
662This removes the <em>WIP</em> commit from the commit history, and sets
663 your working tree to the state just before you made that snapshot.
664</p>
665</li>
666<li>
667<p>
668At this point the index file still has all the WIP changes you
669 committed as <em>snapshot WIP</em>. This updates the index to show your
670 WIP files as uncommitted.
671</p>
Junio C Hamano116db352008-12-17 19:48:40672<div class="para"><p>See also <a href="git-stash.html">git-stash(1)</a>.</p></div>
Junio C Hamanoc8d88c22006-04-29 07:02:01673</li>
Junio C Hamanoba4b9282008-07-06 05:20:31674</ol></div>
Junio C Hamano74e8a2d2006-01-14 03:58:41675</dd>
Junio C Hamano26e590a2008-02-17 03:53:51676<dt>
677Reset a single file in the index
678</dt>
679<dd>
Junio C Hamanoba4b9282008-07-06 05:20:31680<div class="para"><p>Suppose you have added a file to your index, but later decide you do not
Junio C Hamano26e590a2008-02-17 03:53:51681want to add it to your commit. You can remove the file from the index
Junio C Hamanoba4b9282008-07-06 05:20:31682while keeping your changes with git reset.</p></div>
Junio C Hamano26e590a2008-02-17 03:53:51683<div class="listingblock">
684<div class="content">
685<pre><tt>$ git reset -- frotz.c <b>(1)</b>
686$ git commit -m "Commit files in index" <b>(2)</b>
687$ git add frotz.c <b>(3)</b></tt></pre>
688</div></div>
Junio C Hamanoba4b9282008-07-06 05:20:31689<div class="colist"><ol>
Junio C Hamano26e590a2008-02-17 03:53:51690<li>
691<p>
692This removes the file from the index while keeping it in the working
693 directory.
694</p>
695</li>
696<li>
697<p>
698This commits all other changes in the index.
699</p>
700</li>
701<li>
702<p>
703Adds the file to the index again.
704</p>
705</li>
Junio C Hamanoba4b9282008-07-06 05:20:31706</ol></div>
Junio C Hamano26e590a2008-02-17 03:53:51707</dd>
Junio C Hamanoba4b9282008-07-06 05:20:31708</dl></div>
Junio C Hamano1a4e8412005-12-27 08:17:23709</div>
Junio C Hamanoba4b9282008-07-06 05:20:31710<h2 id="_author">Author</h2>
Junio C Hamano1a4e8412005-12-27 08:17:23711<div class="sectionbody">
Junio C Hamano0868a302008-07-22 09:20:44712<div class="para"><p>Written by Junio C Hamano &lt;gitster@pobox.com&gt; and Linus Torvalds &lt;torvalds@osdl.org&gt;</p></div>
Junio C Hamano1a4e8412005-12-27 08:17:23713</div>
Junio C Hamanoba4b9282008-07-06 05:20:31714<h2 id="_documentation">Documentation</h2>
Junio C Hamano1a4e8412005-12-27 08:17:23715<div class="sectionbody">
Junio C Hamanoba4b9282008-07-06 05:20:31716<div class="para"><p>Documentation by Junio C Hamano and the git-list &lt;git@vger.kernel.org&gt;.</p></div>
Junio C Hamano1a4e8412005-12-27 08:17:23717</div>
Junio C Hamanoba4b9282008-07-06 05:20:31718<h2 id="_git">GIT</h2>
Junio C Hamano1a4e8412005-12-27 08:17:23719<div class="sectionbody">
Junio C Hamanoba4b9282008-07-06 05:20:31720<div class="para"><p>Part of the <a href="git.html">git(1)</a> suite</p></div>
Junio C Hamano1a4e8412005-12-27 08:17:23721</div>
722<div id="footer">
723<div id="footer-text">
Junio C Hamanob141a922010-01-10 19:55:14724Last updated 2010-01-10 19:52:59 UTC
Junio C Hamano1a4e8412005-12-27 08:17:23725</div>
726</div>
727</body>
728</html>