blob: 9915c5a1bf390b9640507250df8dda44fe8fde6f [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 Hamano7bd050f2011-09-22 06:32:226<meta name="generator" content="AsciiDoc 8.5.2" />
Junio C Hamano68cf15a2010-11-06 01:01:597<title>git-reset(1)</title>
Junio C Hamano1a4e8412005-12-27 08:17:238<style type="text/css">
9/* Debug borders */
10p, li, dt, dd, div, pre, h1, h2, h3, h4, h5, h6 {
11/*
12 border: 1px solid red;
13*/
14}
15
16body {
17 margin: 1em 5% 1em 5%;
18}
19
Junio C Hamanoba4b9282008-07-06 05:20:3120a {
21 color: blue;
22 text-decoration: underline;
23}
24a:visited {
25 color: fuchsia;
26}
Junio C Hamano1a4e8412005-12-27 08:17:2327
28em {
29 font-style: italic;
Junio C Hamano68cf15a2010-11-06 01:01:5930 color: navy;
Junio C Hamano1a4e8412005-12-27 08:17:2331}
32
33strong {
34 font-weight: bold;
Junio C Hamano68cf15a2010-11-06 01:01:5935 color: #083194;
Junio C Hamano1a4e8412005-12-27 08:17:2336}
37
38tt {
39 color: navy;
40}
41
42h1, h2, h3, h4, h5, h6 {
43 color: #527bbd;
44 font-family: sans-serif;
45 margin-top: 1.2em;
46 margin-bottom: 0.5em;
47 line-height: 1.3;
48}
49
Junio C Hamanoba4b9282008-07-06 05:20:3150h1, h2, h3 {
Junio C Hamano1a4e8412005-12-27 08:17:2351 border-bottom: 2px solid silver;
52}
53h2 {
Junio C Hamano1a4e8412005-12-27 08:17:2354 padding-top: 0.5em;
55}
Junio C Hamanoba4b9282008-07-06 05:20:3156h3 {
57 float: left;
58}
59h3 + * {
60 clear: left;
61}
Junio C Hamano1a4e8412005-12-27 08:17:2362
63div.sectionbody {
64 font-family: serif;
65 margin-left: 0;
66}
67
68hr {
69 border: 1px solid silver;
70}
71
72p {
73 margin-top: 0.5em;
74 margin-bottom: 0.5em;
75}
76
Junio C Hamano68cf15a2010-11-06 01:01:5977ul, ol, li > p {
78 margin-top: 0;
79}
80
Junio C Hamano1a4e8412005-12-27 08:17:2381pre {
82 padding: 0;
83 margin: 0;
84}
85
86span#author {
87 color: #527bbd;
88 font-family: sans-serif;
89 font-weight: bold;
Junio C Hamanoba4b9282008-07-06 05:20:3190 font-size: 1.1em;
Junio C Hamano1a4e8412005-12-27 08:17:2391}
92span#email {
93}
Junio C Hamano68cf15a2010-11-06 01:01:5994span#revnumber, span#revdate, span#revremark {
Junio C Hamano1a4e8412005-12-27 08:17:2395 font-family: sans-serif;
96}
97
98div#footer {
99 font-family: sans-serif;
100 font-size: small;
101 border-top: 2px solid silver;
102 padding-top: 0.5em;
103 margin-top: 4.0em;
104}
105div#footer-text {
106 float: left;
107 padding-bottom: 0.5em;
108}
109div#footer-badges {
110 float: right;
111 padding-bottom: 0.5em;
112}
113
Junio C Hamano68cf15a2010-11-06 01:01:59114div#preamble {
115 margin-top: 1.5em;
116 margin-bottom: 1.5em;
117}
Junio C Hamano1a4e8412005-12-27 08:17:23118div.tableblock, div.imageblock, div.exampleblock, div.verseblock,
119div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock,
120div.admonitionblock {
Junio C Hamano7bd050f2011-09-22 06:32:22121 margin-top: 1.0em;
Junio C Hamano1a4e8412005-12-27 08:17:23122 margin-bottom: 1.5em;
123}
124div.admonitionblock {
Junio C Hamano7bd050f2011-09-22 06:32:22125 margin-top: 2.0em;
126 margin-bottom: 2.0em;
127 margin-right: 10%;
128 color: #606060;
Junio C Hamano1a4e8412005-12-27 08:17:23129}
130
131div.content { /* Block element content. */
132 padding: 0;
133}
134
135/* Block element titles. */
136div.title, caption.title {
Junio C Hamano68cf15a2010-11-06 01:01:59137 color: #527bbd;
Junio C Hamano1a4e8412005-12-27 08:17:23138 font-family: sans-serif;
139 font-weight: bold;
140 text-align: left;
141 margin-top: 1.0em;
142 margin-bottom: 0.5em;
143}
144div.title + * {
145 margin-top: 0;
146}
147
148td div.title:first-child {
149 margin-top: 0.0em;
150}
151div.content div.title:first-child {
152 margin-top: 0.0em;
153}
154div.content + div.title {
155 margin-top: 0.0em;
156}
157
158div.sidebarblock > div.content {
159 background: #ffffee;
160 border: 1px solid silver;
161 padding: 0.5em;
162}
163
164div.listingblock > div.content {
165 border: 1px solid silver;
166 background: #f4f4f4;
167 padding: 0.5em;
168}
169
Junio C Hamano7bd050f2011-09-22 06:32:22170div.quoteblock, div.verseblock {
171 padding-left: 1.0em;
172 margin-left: 1.0em;
Junio C Hamano68cf15a2010-11-06 01:01:59173 margin-right: 10%;
Junio C Hamano7bd050f2011-09-22 06:32:22174 border-left: 5px solid #dddddd;
175 color: #777777;
Junio C Hamano1a4e8412005-12-27 08:17:23176}
Junio C Hamano7bd050f2011-09-22 06:32:22177
Junio C Hamano68cf15a2010-11-06 01:01:59178div.quoteblock > div.attribution {
179 padding-top: 0.5em;
Junio C Hamano1a4e8412005-12-27 08:17:23180 text-align: right;
181}
Junio C Hamano68cf15a2010-11-06 01:01:59182
Junio C Hamano68cf15a2010-11-06 01:01:59183div.verseblock > div.content {
184 white-space: pre;
185}
186div.verseblock > div.attribution {
187 padding-top: 0.75em;
188 text-align: left;
189}
190/* DEPRECATED: Pre version 8.2.7 verse style literal block. */
Junio C Hamanoba4b9282008-07-06 05:20:31191div.verseblock + div.attribution {
192 text-align: left;
193}
Junio C Hamano1a4e8412005-12-27 08:17:23194
195div.admonitionblock .icon {
196 vertical-align: top;
197 font-size: 1.1em;
198 font-weight: bold;
199 text-decoration: underline;
200 color: #527bbd;
201 padding-right: 0.5em;
202}
203div.admonitionblock td.content {
204 padding-left: 0.5em;
Junio C Hamano7bd050f2011-09-22 06:32:22205 border-left: 3px solid #dddddd;
Junio C Hamano1a4e8412005-12-27 08:17:23206}
207
208div.exampleblock > div.content {
Junio C Hamano7bd050f2011-09-22 06:32:22209 border-left: 3px solid #dddddd;
210 padding-left: 0.5em;
Junio C Hamano1a4e8412005-12-27 08:17:23211}
212
Junio C Hamano1a4e8412005-12-27 08:17:23213div.imageblock div.content { padding-left: 0; }
Junio C Hamano1a4e8412005-12-27 08:17:23214span.image img { border-style: none; }
Junio C Hamano68cf15a2010-11-06 01:01:59215a.image:visited { color: white; }
Junio C Hamano1a4e8412005-12-27 08:17:23216
217dl {
218 margin-top: 0.8em;
219 margin-bottom: 0.8em;
220}
221dt {
222 margin-top: 0.5em;
223 margin-bottom: 0;
Junio C Hamano68cf15a2010-11-06 01:01:59224 font-style: normal;
225 color: navy;
Junio C Hamano1a4e8412005-12-27 08:17:23226}
227dd > *:first-child {
Junio C Hamano68cf15a2010-11-06 01:01:59228 margin-top: 0.1em;
Junio C Hamano1a4e8412005-12-27 08:17:23229}
230
231ul, ol {
232 list-style-position: outside;
233}
Junio C Hamano68cf15a2010-11-06 01:01:59234ol.arabic {
235 list-style-type: decimal;
236}
237ol.loweralpha {
Junio C Hamano1a4e8412005-12-27 08:17:23238 list-style-type: lower-alpha;
239}
Junio C Hamano68cf15a2010-11-06 01:01:59240ol.upperalpha {
241 list-style-type: upper-alpha;
242}
243ol.lowerroman {
244 list-style-type: lower-roman;
245}
246ol.upperroman {
247 list-style-type: upper-roman;
248}
249
250div.compact ul, div.compact ol,
251div.compact p, div.compact p,
252div.compact div, div.compact div {
253 margin-top: 0.1em;
254 margin-bottom: 0.1em;
255}
Junio C Hamano1a4e8412005-12-27 08:17:23256
257div.tableblock > table {
Junio C Hamanoba4b9282008-07-06 05:20:31258 border: 3px solid #527bbd;
Junio C Hamano1a4e8412005-12-27 08:17:23259}
Junio C Hamano7bd050f2011-09-22 06:32:22260thead, p.table.header {
Junio C Hamano1a4e8412005-12-27 08:17:23261 font-family: sans-serif;
262 font-weight: bold;
263}
264tfoot {
265 font-weight: bold;
266}
Junio C Hamano68cf15a2010-11-06 01:01:59267td > div.verse {
268 white-space: pre;
269}
270p.table {
271 margin-top: 0;
272}
273/* Because the table frame attribute is overriden by CSS in most browsers. */
274div.tableblock > table[frame="void"] {
275 border-style: none;
276}
277div.tableblock > table[frame="hsides"] {
278 border-left-style: none;
279 border-right-style: none;
280}
281div.tableblock > table[frame="vsides"] {
282 border-top-style: none;
283 border-bottom-style: none;
284}
Junio C Hamano1a4e8412005-12-27 08:17:23285
Junio C Hamano68cf15a2010-11-06 01:01:59286
287div.hdlist {
Junio C Hamano1a4e8412005-12-27 08:17:23288 margin-top: 0.8em;
289 margin-bottom: 0.8em;
290}
Junio C Hamano68cf15a2010-11-06 01:01:59291div.hdlist tr {
292 padding-bottom: 15px;
Junio C Hamanoba4b9282008-07-06 05:20:31293}
Junio C Hamano68cf15a2010-11-06 01:01:59294dt.hdlist1.strong, td.hdlist1.strong {
295 font-weight: bold;
296}
297td.hdlist1 {
Junio C Hamano1a4e8412005-12-27 08:17:23298 vertical-align: top;
Junio C Hamano68cf15a2010-11-06 01:01:59299 font-style: normal;
Junio C Hamano1a4e8412005-12-27 08:17:23300 padding-right: 0.8em;
Junio C Hamano68cf15a2010-11-06 01:01:59301 color: navy;
Junio C Hamano1a4e8412005-12-27 08:17:23302}
Junio C Hamano68cf15a2010-11-06 01:01:59303td.hdlist2 {
Junio C Hamano1a4e8412005-12-27 08:17:23304 vertical-align: top;
305}
Junio C Hamano68cf15a2010-11-06 01:01:59306div.hdlist.compact tr {
307 margin: 0;
308 padding-bottom: 0;
309}
310
311.comment {
312 background: yellow;
313}
Junio C Hamano1a4e8412005-12-27 08:17:23314
Junio C Hamano7bd050f2011-09-22 06:32:22315.footnote, .footnoteref {
316 font-size: 0.8em;
317}
318
319span.footnote, span.footnoteref {
320 vertical-align: super;
321}
322
323#footnotes {
324 margin: 20px 0 20px 0;
325 padding: 7px 0 0 0;
326}
327
328#footnotes div.footnote {
329 margin: 0 0 5px 0;
330}
331
332#footnotes hr {
333 border: none;
334 border-top: 1px solid silver;
335 height: 1px;
336 text-align: left;
337 margin-left: 0;
338 width: 20%;
339 min-width: 100px;
340}
341
342
Junio C Hamano1a4e8412005-12-27 08:17:23343@media print {
344 div#footer-badges { display: none; }
345}
Junio C Hamanoba4b9282008-07-06 05:20:31346
Junio C Hamano7bd050f2011-09-22 06:32:22347div#toc {
348 margin-bottom: 2.5em;
349}
350
Junio C Hamanoba4b9282008-07-06 05:20:31351div#toctitle {
352 color: #527bbd;
353 font-family: sans-serif;
354 font-size: 1.1em;
355 font-weight: bold;
356 margin-top: 1.0em;
357 margin-bottom: 0.1em;
358}
359
360div.toclevel1, div.toclevel2, div.toclevel3, div.toclevel4 {
361 margin-top: 0;
362 margin-bottom: 0;
363}
364div.toclevel2 {
365 margin-left: 2em;
366 font-size: 0.9em;
367}
368div.toclevel3 {
369 margin-left: 4em;
370 font-size: 0.9em;
371}
372div.toclevel4 {
373 margin-left: 6em;
374 font-size: 0.9em;
375}
Junio C Hamano68cf15a2010-11-06 01:01:59376/* Overrides for manpage documents */
377h1 {
378 padding-top: 0.5em;
379 padding-bottom: 0.5em;
380 border-top: 2px solid silver;
381 border-bottom: 2px solid silver;
382}
383h2 {
384 border-style: none;
385}
386div.sectionbody {
387 margin-left: 5%;
388}
389
390@media print {
391 div#toc { display: none; }
392}
393
Junio C Hamano1a4e8412005-12-27 08:17:23394/* Workarounds for IE6's broken and incomplete CSS2. */
395
396div.sidebar-content {
397 background: #ffffee;
398 border: 1px solid silver;
399 padding: 0.5em;
400}
401div.sidebar-title, div.image-title {
Junio C Hamano68cf15a2010-11-06 01:01:59402 color: #527bbd;
Junio C Hamano1a4e8412005-12-27 08:17:23403 font-family: sans-serif;
404 font-weight: bold;
405 margin-top: 0.0em;
406 margin-bottom: 0.5em;
407}
408
409div.listingblock div.content {
410 border: 1px solid silver;
411 background: #f4f4f4;
412 padding: 0.5em;
413}
414
Junio C Hamano68cf15a2010-11-06 01:01:59415div.quoteblock-attribution {
416 padding-top: 0.5em;
417 text-align: right;
418}
419
420div.verseblock-content {
421 white-space: pre;
422}
423div.verseblock-attribution {
424 padding-top: 0.75em;
425 text-align: left;
Junio C Hamano1a4e8412005-12-27 08:17:23426}
427
428div.exampleblock-content {
Junio C Hamano7bd050f2011-09-22 06:32:22429 border-left: 3px solid #dddddd;
Junio C Hamano1a4e8412005-12-27 08:17:23430 padding-left: 0.5em;
431}
Junio C Hamanoba4b9282008-07-06 05:20:31432
433/* IE6 sets dynamically generated links as visited. */
434div#toc a:visited { color: blue; }
Junio C Hamano1a4e8412005-12-27 08:17:23435</style>
Junio C Hamano7bd050f2011-09-22 06:32:22436<script type="text/javascript">
437/*<![CDATA[*/
438window.onload = function(){asciidoc.footnotes();}
439var asciidoc = { // Namespace.
440
441/////////////////////////////////////////////////////////////////////
442// Table Of Contents generator
443/////////////////////////////////////////////////////////////////////
444
445/* Author: Mihai Bazon, September 2002
446 * http://students.infoiasi.ro/~mishoo
447 *
448 * Table Of Content generator
449 * Version: 0.4
450 *
451 * Feel free to use this script under the terms of the GNU General Public
452 * License, as long as you do not remove or alter this notice.
453 */
454
455 /* modified by Troy D. Hanson, September 2006. License: GPL */
456 /* modified by Stuart Rackham, 2006, 2009. License: GPL */
457
458// toclevels = 1..4.
459toc: function (toclevels) {
460
461 function getText(el) {
462 var text = "";
463 for (var i = el.firstChild; i != null; i = i.nextSibling) {
464 if (i.nodeType == 3 /* Node.TEXT_NODE */) // IE doesn't speak constants.
465 text += i.data;
466 else if (i.firstChild != null)
467 text += getText(i);
468 }
469 return text;
470 }
471
472 function TocEntry(el, text, toclevel) {
473 this.element = el;
474 this.text = text;
475 this.toclevel = toclevel;
476 }
477
478 function tocEntries(el, toclevels) {
479 var result = new Array;
480 var re = new RegExp('[hH]([2-'+(toclevels+1)+'])');
481 // Function that scans the DOM tree for header elements (the DOM2
482 // nodeIterator API would be a better technique but not supported by all
483 // browsers).
484 var iterate = function (el) {
485 for (var i = el.firstChild; i != null; i = i.nextSibling) {
486 if (i.nodeType == 1 /* Node.ELEMENT_NODE */) {
487 var mo = re.exec(i.tagName);
488 if (mo && (i.getAttribute("class") || i.getAttribute("className")) != "float") {
489 result[result.length] = new TocEntry(i, getText(i), mo[1]-1);
490 }
491 iterate(i);
492 }
493 }
494 }
495 iterate(el);
496 return result;
497 }
498
499 var toc = document.getElementById("toc");
500 var entries = tocEntries(document.getElementById("content"), toclevels);
501 for (var i = 0; i < entries.length; ++i) {
502 var entry = entries[i];
503 if (entry.element.id == "")
504 entry.element.id = "_toc_" + i;
505 var a = document.createElement("a");
506 a.href = "#" + entry.element.id;
507 a.appendChild(document.createTextNode(entry.text));
508 var div = document.createElement("div");
509 div.appendChild(a);
510 div.className = "toclevel" + entry.toclevel;
511 toc.appendChild(div);
512 }
513 if (entries.length == 0)
514 toc.parentNode.removeChild(toc);
515},
516
517
518/////////////////////////////////////////////////////////////////////
519// Footnotes generator
520/////////////////////////////////////////////////////////////////////
521
522/* Based on footnote generation code from:
523 * http://www.brandspankingnew.net/archive/2005/07/format_footnote.html
524 */
525
526footnotes: function () {
527 var cont = document.getElementById("content");
528 var noteholder = document.getElementById("footnotes");
529 var spans = cont.getElementsByTagName("span");
530 var refs = {};
531 var n = 0;
532 for (i=0; i<spans.length; i++) {
533 if (spans[i].className == "footnote") {
534 n++;
535 // Use [\s\S] in place of . so multi-line matches work.
536 // Because JavaScript has no s (dotall) regex flag.
537 note = spans[i].innerHTML.match(/\s*\[([\s\S]*)]\s*/)[1];
538 noteholder.innerHTML +=
539 "<div class='footnote' id='_footnote_" + n + "'>" +
540 "<a href='#_footnoteref_" + n + "' title='Return to text'>" +
541 n + "</a>. " + note + "</div>";
542 spans[i].innerHTML =
543 "[<a id='_footnoteref_" + n + "' href='#_footnote_" + n +
544 "' title='View footnote' class='footnote'>" + n + "</a>]";
545 var id =spans[i].getAttribute("id");
546 if (id != null) refs["#"+id] = n;
547 }
548 }
549 if (n == 0)
550 noteholder.parentNode.removeChild(noteholder);
551 else {
552 // Process footnoterefs.
553 for (i=0; i<spans.length; i++) {
554 if (spans[i].className == "footnoteref") {
555 var href = spans[i].getElementsByTagName("a")[0].getAttribute("href");
556 href = href.match(/#.*/)[0]; // Because IE return full URL.
557 n = refs[href];
558 spans[i].innerHTML =
559 "[<a href='#_footnote_" + n +
560 "' title='View footnote' class='footnote'>" + n + "</a>]";
561 }
562 }
563 }
564}
565
566}
567/*]]>*/
568</script>
Junio C Hamano1a4e8412005-12-27 08:17:23569</head>
570<body>
571<div id="header">
572<h1>
573git-reset(1) Manual Page
574</h1>
575<h2>NAME</h2>
576<div class="sectionbody">
577<p>git-reset -
Junio C Hamano01078922006-03-10 00:31:47578 Reset current HEAD to the specified state
Junio C Hamano1a4e8412005-12-27 08:17:23579</p>
580</div>
581</div>
Junio C Hamano7bd050f2011-09-22 06:32:22582<div id="content">
Junio C Hamano68cf15a2010-11-06 01:01:59583<h2 id="_synopsis">SYNOPSIS</h2>
Junio C Hamano1a4e8412005-12-27 08:17:23584<div class="sectionbody">
Junio C Hamanod793de52006-12-26 09:11:43585<div class="verseblock">
Junio C Hamano68cf15a2010-11-06 01:01:59586<div class="verseblock-content"><em>git reset</em> [-q] [&lt;commit&gt;] [--] &lt;paths&gt;&#8230;
Junio C Hamanof0944d02011-11-30 20:46:29587<em>git reset</em> (--patch | -p) [&lt;commit&gt;] [--] [&lt;paths&gt;&#8230;]
588<em>git reset</em> (--soft | --mixed | --hard | --merge | --keep) [-q] [&lt;commit&gt;]</div>
Junio C Hamano68cf15a2010-11-06 01:01:59589<div class="verseblock-attribution">
590</div></div>
Junio C Hamano1a4e8412005-12-27 08:17:23591</div>
Junio C Hamanoba4b9282008-07-06 05:20:31592<h2 id="_description">DESCRIPTION</h2>
Junio C Hamano1a4e8412005-12-27 08:17:23593<div class="sectionbody">
Junio C Hamano68cf15a2010-11-06 01:01:59594<div class="paragraph"><p>In the first and second form, copy entries from &lt;commit&gt; to the index.
Junio C Hamano657fd8a2010-10-07 00:01:24595In the third form, set the current branch head (HEAD) to &lt;commit&gt;, optionally
596modifying index and working tree to match. The &lt;commit&gt; defaults to HEAD
Junio C Hamanob5a296f2010-08-13 02:46:36597in all forms.</p></div>
Junio C Hamano68cf15a2010-11-06 01:01:59598<div class="dlist"><dl>
599<dt class="hdlist1">
Junio C Hamanob5a296f2010-08-13 02:46:36600<em>git reset</em> [-q] [&lt;commit&gt;] [--] &lt;paths&gt;&#8230;
Junio C Hamano1a4e8412005-12-27 08:17:23601</dt>
602<dd>
603<p>
Junio C Hamanob5a296f2010-08-13 02:46:36604 This form resets the index entries for all &lt;paths&gt; to their
Junio C Hamano657fd8a2010-10-07 00:01:24605 state at &lt;commit&gt;. (It does not affect the working tree, nor
Junio C Hamanob5a296f2010-08-13 02:46:36606 the current branch.)
Junio C Hamano1a4e8412005-12-27 08:17:23607</p>
Junio C Hamano68cf15a2010-11-06 01:01:59608<div class="paragraph"><p>This means that <tt>git reset &lt;paths&gt;</tt> is the opposite of <tt>git add
Junio C Hamanob5a296f2010-08-13 02:46:36609&lt;paths&gt;</tt>.</p></div>
Junio C Hamano68cf15a2010-11-06 01:01:59610<div class="paragraph"><p>After running <tt>git reset &lt;paths&gt;</tt> to update the index entry, you can
Junio C Hamano657fd8a2010-10-07 00:01:24611use <a href="git-checkout.html">git-checkout(1)</a> to check the contents out of the index to
612the working tree.
613Alternatively, using <a href="git-checkout.html">git-checkout(1)</a> and specifying a commit, you
614can copy the contents of a path out of a commit to the index and to the
615working tree in one go.</p></div>
Junio C Hamano1a4e8412005-12-27 08:17:23616</dd>
Junio C Hamano68cf15a2010-11-06 01:01:59617<dt class="hdlist1">
Junio C Hamanof0944d02011-11-30 20:46:29618<em>git reset</em> (--patch | -p) [&lt;commit&gt;] [--] [&lt;paths&gt;&#8230;]
Junio C Hamanob5a296f2010-08-13 02:46:36619</dt>
620<dd>
621<p>
622 Interactively select hunks in the difference between the index
623 and &lt;commit&gt; (defaults to HEAD). The chosen hunks are applied
624 in reverse to the index.
625</p>
Junio C Hamano9eb58352011-05-11 20:09:24626<div class="paragraph"><p>This means that <tt>git reset -p</tt> is the opposite of <tt>git add -p</tt>, i.e.
627you can use it to selectively reset hunks. See the &#8220;Interactive Mode&#8221;
628section of <a href="git-add.html">git-add(1)</a> to learn how to operate the <tt>--patch</tt> mode.</p></div>
Junio C Hamanob5a296f2010-08-13 02:46:36629</dd>
Junio C Hamano68cf15a2010-11-06 01:01:59630<dt class="hdlist1">
Junio C Hamanof0944d02011-11-30 20:46:29631<em>git reset</em> --&lt;mode&gt; [&lt;commit&gt;]
Junio C Hamanob5a296f2010-08-13 02:46:36632</dt>
633<dd>
634<p>
Junio C Hamano657fd8a2010-10-07 00:01:24635 This form resets the current branch head to &lt;commit&gt; and
636 possibly updates the index (resetting it to the tree of &lt;commit&gt;) and
637 the working tree depending on &lt;mode&gt;, which
638 must be one of the following:
Junio C Hamanob5a296f2010-08-13 02:46:36639</p>
Junio C Hamano68cf15a2010-11-06 01:01:59640<div class="dlist"><dl>
641<dt class="hdlist1">
Junio C Hamano1a4e8412005-12-27 08:17:23642--soft
643</dt>
644<dd>
645<p>
Junio C Hamano657fd8a2010-10-07 00:01:24646 Does not touch the index file nor the working tree at all (but
647 resets the head to &lt;commit&gt;, just like all modes do). This leaves
648 all your changed files "Changes to be committed", as <em>git status</em>
649 would put it.
Junio C Hamano1a4e8412005-12-27 08:17:23650</p>
651</dd>
Junio C Hamano68cf15a2010-11-06 01:01:59652<dt class="hdlist1">
Junio C Hamanob5a296f2010-08-13 02:46:36653--mixed
654</dt>
655<dd>
656<p>
657 Resets the index but not the working tree (i.e., the changed files
658 are preserved but not marked for commit) and reports what has not
659 been updated. This is the default action.
660</p>
661</dd>
Junio C Hamano68cf15a2010-11-06 01:01:59662<dt class="hdlist1">
Junio C Hamano1a4e8412005-12-27 08:17:23663--hard
664</dt>
665<dd>
666<p>
Junio C Hamano657fd8a2010-10-07 00:01:24667 Resets the index and working tree. Any changes to tracked files in the
668 working tree since &lt;commit&gt; are discarded.
Junio C Hamano1a4e8412005-12-27 08:17:23669</p>
670</dd>
Junio C Hamano68cf15a2010-11-06 01:01:59671<dt class="hdlist1">
Junio C Hamanobbbb8652008-12-29 10:34:22672--merge
673</dt>
674<dd>
675<p>
Junio C Hamano657fd8a2010-10-07 00:01:24676 Resets the index and updates the files in the working tree that are
677 different between &lt;commit&gt; and HEAD, but keeps those which are
678 different between the index and working tree (i.e. which have changes
679 which have not been added).
680 If a file that is different between &lt;commit&gt; and the index has unstaged
Junio C Hamano68cf15a2010-11-06 01:01:59681 changes, reset is aborted.
Junio C Hamanobbbb8652008-12-29 10:34:22682</p>
Junio C Hamano68cf15a2010-11-06 01:01:59683<div class="paragraph"><p>In other words, --merge does something like a <em>git read-tree -u -m &lt;commit&gt;</em>,
684but carries forward unmerged index entries.</p></div>
Junio C Hamanobbbb8652008-12-29 10:34:22685</dd>
Junio C Hamano68cf15a2010-11-06 01:01:59686<dt class="hdlist1">
Junio C Hamano0299d922010-03-20 20:59:31687--keep
688</dt>
689<dd>
690<p>
Junio C Hamano20338b42011-01-22 00:51:59691 Resets index entries and updates files in the working tree that are
692 different between &lt;commit&gt; and HEAD.
Junio C Hamano657fd8a2010-10-07 00:01:24693 If a file that is different between &lt;commit&gt; and HEAD has local changes,
Junio C Hamano68cf15a2010-11-06 01:01:59694 reset is aborted.
Junio C Hamano0299d922010-03-20 20:59:31695</p>
696</dd>
Junio C Hamanob5a296f2010-08-13 02:46:36697</dl></div>
Junio C Hamanoc28068f2009-09-08 00:55:23698</dd>
Junio C Hamanob5a296f2010-08-13 02:46:36699</dl></div>
Junio C Hamano68cf15a2010-11-06 01:01:59700<div class="paragraph"><p>If you want to undo a commit other than the latest on a branch,
Junio C Hamanob5a296f2010-08-13 02:46:36701<a href="git-revert.html">git-revert(1)</a> is your friend.</p></div>
702</div>
703<h2 id="_options">OPTIONS</h2>
704<div class="sectionbody">
Junio C Hamano68cf15a2010-11-06 01:01:59705<div class="dlist"><dl>
706<dt class="hdlist1">
Junio C Hamano422cfec2007-11-08 08:07:45707-q
708</dt>
Junio C Hamano68cf15a2010-11-06 01:01:59709<dt class="hdlist1">
Junio C Hamanob141a922010-01-10 19:55:14710--quiet
711</dt>
Junio C Hamano422cfec2007-11-08 08:07:45712<dd>
713<p>
714 Be quiet, only report errors.
715</p>
716</dd>
Junio C Hamanoba4b9282008-07-06 05:20:31717</dl></div>
Junio C Hamano1bb569e2006-05-05 23:14:25718</div>
Junio C Hamanob5a296f2010-08-13 02:46:36719<h2 id="_examples">EXAMPLES</h2>
Junio C Hamano1bb569e2006-05-05 23:14:25720<div class="sectionbody">
Junio C Hamano68cf15a2010-11-06 01:01:59721<div class="dlist"><dl>
722<dt class="hdlist1">
Junio C Hamano89d4e0f2007-02-18 00:34:59723Undo add
Junio C Hamano1a4e8412005-12-27 08:17:23724</dt>
725<dd>
726<div class="listingblock">
727<div class="content">
Junio C Hamano68cf15a2010-11-06 01:01:59728<pre><tt>$ edit <b>&lt;1&gt;</b>
Junio C Hamano89d4e0f2007-02-18 00:34:59729$ git add frotz.c filfre.c
Junio C Hamano68cf15a2010-11-06 01:01:59730$ mailx <b>&lt;2&gt;</b>
731$ git reset <b>&lt;3&gt;</b>
732$ git pull git://info.example.com/ nitfol <b>&lt;4&gt;</b></tt></pre>
Junio C Hamanoc8d88c22006-04-29 07:02:01733</div></div>
Junio C Hamano68cf15a2010-11-06 01:01:59734<div class="colist arabic"><ol>
Junio C Hamanoc8d88c22006-04-29 07:02:01735<li>
736<p>
Junio C Hamano092f5f02007-08-02 07:23:38737You are happily working on something, and find the changes
Junio C Hamano1a4e8412005-12-27 08:17:23738in these files are in good order. You do not want to see them
739when you run "git diff", because you plan to work on other files
740and changes with these files are distracting.
Junio C Hamanoc8d88c22006-04-29 07:02:01741</p>
742</li>
743<li>
744<p>
Junio C Hamano092f5f02007-08-02 07:23:38745Somebody asks you to pull, and the changes sounds worthy of merging.
Junio C Hamanoc8d88c22006-04-29 07:02:01746</p>
747</li>
748<li>
749<p>
Junio C Hamano092f5f02007-08-02 07:23:38750However, you already dirtied the index (i.e. your index does
Junio C Hamano1a4e8412005-12-27 08:17:23751not match the HEAD commit). But you know the pull you are going
752to make does not affect frotz.c nor filfre.c, so you revert the
753index changes for these two files. Your changes in working tree
754remain there.
Junio C Hamanoc8d88c22006-04-29 07:02:01755</p>
756</li>
757<li>
758<p>
Junio C Hamano092f5f02007-08-02 07:23:38759Then you can pull and merge, leaving frotz.c and filfre.c
Junio C Hamanoc8d88c22006-04-29 07:02:01760changes still in the working tree.
761</p>
762</li>
Junio C Hamanoba4b9282008-07-06 05:20:31763</ol></div>
Junio C Hamano1a4e8412005-12-27 08:17:23764</dd>
Junio C Hamano68cf15a2010-11-06 01:01:59765<dt class="hdlist1">
Junio C Hamanob5a296f2010-08-13 02:46:36766Undo a commit and redo
767</dt>
768<dd>
769<div class="listingblock">
770<div class="content">
771<pre><tt>$ git commit ...
Junio C Hamano68cf15a2010-11-06 01:01:59772$ git reset --soft HEAD^ <b>&lt;1&gt;</b>
773$ edit <b>&lt;2&gt;</b>
774$ git commit -a -c ORIG_HEAD <b>&lt;3&gt;</b></tt></pre>
Junio C Hamanob5a296f2010-08-13 02:46:36775</div></div>
Junio C Hamano68cf15a2010-11-06 01:01:59776<div class="colist arabic"><ol>
Junio C Hamanob5a296f2010-08-13 02:46:36777<li>
778<p>
779This is most often done when you remembered what you
780just committed is incomplete, or you misspelled your commit
781message, or both. Leaves working tree as it was before "reset".
782</p>
783</li>
784<li>
785<p>
786Make corrections to working tree files.
787</p>
788</li>
789<li>
790<p>
791"reset" copies the old head to .git/ORIG_HEAD; redo the
792commit by starting with its log message. If you do not need to
793edit the message further, you can give -C option instead.
794</p>
Junio C Hamano68cf15a2010-11-06 01:01:59795<div class="paragraph"><p>See also the --amend option to <a href="git-commit.html">git-commit(1)</a>.</p></div>
Junio C Hamanob5a296f2010-08-13 02:46:36796</li>
797</ol></div>
798</dd>
Junio C Hamano68cf15a2010-11-06 01:01:59799<dt class="hdlist1">
Junio C Hamanob5a296f2010-08-13 02:46:36800Undo a commit, making it a topic branch
801</dt>
802<dd>
803<div class="listingblock">
804<div class="content">
Junio C Hamano68cf15a2010-11-06 01:01:59805<pre><tt>$ git branch topic/wip <b>&lt;1&gt;</b>
806$ git reset --hard HEAD~3 <b>&lt;2&gt;</b>
807$ git checkout topic/wip <b>&lt;3&gt;</b></tt></pre>
Junio C Hamanob5a296f2010-08-13 02:46:36808</div></div>
Junio C Hamano68cf15a2010-11-06 01:01:59809<div class="colist arabic"><ol>
Junio C Hamanob5a296f2010-08-13 02:46:36810<li>
811<p>
812You have made some commits, but realize they were premature
813to be in the "master" branch. You want to continue polishing
814them in a topic branch, so create "topic/wip" branch off of the
815current HEAD.
816</p>
817</li>
818<li>
819<p>
820Rewind the master branch to get rid of those three commits.
821</p>
822</li>
823<li>
824<p>
825Switch to "topic/wip" branch and keep working.
826</p>
827</li>
828</ol></div>
829</dd>
Junio C Hamano68cf15a2010-11-06 01:01:59830<dt class="hdlist1">
Junio C Hamanob5a296f2010-08-13 02:46:36831Undo commits permanently
832</dt>
833<dd>
834<div class="listingblock">
835<div class="content">
836<pre><tt>$ git commit ...
Junio C Hamano68cf15a2010-11-06 01:01:59837$ git reset --hard HEAD~3 <b>&lt;1&gt;</b></tt></pre>
Junio C Hamanob5a296f2010-08-13 02:46:36838</div></div>
Junio C Hamano68cf15a2010-11-06 01:01:59839<div class="colist arabic"><ol>
Junio C Hamanob5a296f2010-08-13 02:46:36840<li>
841<p>
842The last three commits (HEAD, HEAD^, and HEAD~2) were bad
843and you do not want to ever see them again. Do <strong>not</strong> do this if
844you have already given these commits to somebody else. (See the
845"RECOVERING FROM UPSTREAM REBASE" section in <a href="git-rebase.html">git-rebase(1)</a> for
846the implications of doing so.)
847</p>
848</li>
849</ol></div>
850</dd>
Junio C Hamano68cf15a2010-11-06 01:01:59851<dt class="hdlist1">
Junio C Hamano1a4e8412005-12-27 08:17:23852Undo a merge or pull
853</dt>
854<dd>
855<div class="listingblock">
856<div class="content">
Junio C Hamano68cf15a2010-11-06 01:01:59857<pre><tt>$ git pull <b>&lt;1&gt;</b>
Junio C Hamano1a4e8412005-12-27 08:17:23858Auto-merging nitfol
859CONFLICT (content): Merge conflict in nitfol
Junio C Hamano6a3c8272008-12-19 21:38:18860Automatic merge failed; fix conflicts and then commit the result.
Junio C Hamano68cf15a2010-11-06 01:01:59861$ git reset --hard <b>&lt;2&gt;</b>
862$ git pull . topic/branch <b>&lt;3&gt;</b>
Junio C Hamano1a4e8412005-12-27 08:17:23863Updating from 41223... to 13134...
Junio C Hamano3f680f32009-11-16 02:10:54864Fast-forward
Junio C Hamano68cf15a2010-11-06 01:01:59865$ git reset --hard ORIG_HEAD <b>&lt;4&gt;</b></tt></pre>
Junio C Hamanoc8d88c22006-04-29 07:02:01866</div></div>
Junio C Hamano68cf15a2010-11-06 01:01:59867<div class="colist arabic"><ol>
Junio C Hamanoc8d88c22006-04-29 07:02:01868<li>
869<p>
Junio C Hamano092f5f02007-08-02 07:23:38870Try to update from the upstream resulted in a lot of
Junio C Hamanoc8d88c22006-04-29 07:02:01871conflicts; you were not ready to spend a lot of time merging
872right now, so you decide to do that later.
873</p>
874</li>
875<li>
876<p>
877"pull" has not made merge commit, so "git reset --hard"
878which is a synonym for "git reset --hard HEAD" clears the mess
879from the index file and the working tree.
880</p>
881</li>
882<li>
883<p>
Junio C Hamano092f5f02007-08-02 07:23:38884Merge a topic branch into the current branch, which resulted
Junio C Hamano3f680f32009-11-16 02:10:54885in a fast-forward.
Junio C Hamanoc8d88c22006-04-29 07:02:01886</p>
887</li>
888<li>
889<p>
Junio C Hamano092f5f02007-08-02 07:23:38890But you decided that the topic branch is not ready for public
Junio C Hamano1a4e8412005-12-27 08:17:23891consumption yet. "pull" or "merge" always leaves the original
892tip of the current branch in ORIG_HEAD, so resetting hard to it
893brings your index file and the working tree back to that state,
Junio C Hamanoc8d88c22006-04-29 07:02:01894and resets the tip of the branch to that commit.
895</p>
896</li>
Junio C Hamanoba4b9282008-07-06 05:20:31897</ol></div>
Junio C Hamano1a4e8412005-12-27 08:17:23898</dd>
Junio C Hamano68cf15a2010-11-06 01:01:59899<dt class="hdlist1">
Junio C Hamano657fd8a2010-10-07 00:01:24900Undo a merge or pull inside a dirty working tree
Junio C Hamanobbbb8652008-12-29 10:34:22901</dt>
902<dd>
903<div class="listingblock">
904<div class="content">
Junio C Hamano68cf15a2010-11-06 01:01:59905<pre><tt>$ git pull <b>&lt;1&gt;</b>
Junio C Hamanobbbb8652008-12-29 10:34:22906Auto-merging nitfol
907Merge made by recursive.
908 nitfol | 20 +++++----
909 ...
Junio C Hamano68cf15a2010-11-06 01:01:59910$ git reset --merge ORIG_HEAD <b>&lt;2&gt;</b></tt></pre>
Junio C Hamanobbbb8652008-12-29 10:34:22911</div></div>
Junio C Hamano68cf15a2010-11-06 01:01:59912<div class="colist arabic"><ol>
Junio C Hamanobbbb8652008-12-29 10:34:22913<li>
914<p>
915Even if you may have local modifications in your
916working tree, you can safely say "git pull" when you know
917that the change in the other branch does not overlap with
918them.
919</p>
920</li>
921<li>
922<p>
923After inspecting the result of the merge, you may find
924that the change in the other branch is unsatisfactory. Running
925"git reset --hard ORIG_HEAD" will let you go back to where you
926were, but it will discard your local changes, which you do not
927want. "git reset --merge" keeps your local changes.
928</p>
929</li>
930</ol></div>
931</dd>
Junio C Hamano68cf15a2010-11-06 01:01:59932<dt class="hdlist1">
Junio C Hamano74e8a2d2006-01-14 03:58:41933Interrupted workflow
934</dt>
935<dd>
Junio C Hamano68cf15a2010-11-06 01:01:59936<div class="paragraph"><p>Suppose you are interrupted by an urgent fix request while you
Junio C Hamanoa6331a82006-01-22 07:50:33937are in the middle of a large change. The files in your
Junio C Hamano74e8a2d2006-01-14 03:58:41938working tree are not in any shape to be committed yet, but you
Junio C Hamanoba4b9282008-07-06 05:20:31939need to get to the other branch for a quick bugfix.</p></div>
Junio C Hamano74e8a2d2006-01-14 03:58:41940<div class="listingblock">
941<div class="content">
942<pre><tt>$ git checkout feature ;# you were working in "feature" branch and
943$ work work work ;# got interrupted
Junio C Hamano68cf15a2010-11-06 01:01:59944$ git commit -a -m "snapshot WIP" <b>&lt;1&gt;</b>
Junio C Hamano74e8a2d2006-01-14 03:58:41945$ git checkout master
946$ fix fix fix
947$ git commit ;# commit with real log
948$ git checkout feature
Junio C Hamano68cf15a2010-11-06 01:01:59949$ git reset --soft HEAD^ ;# go back to WIP state <b>&lt;2&gt;</b>
950$ git reset <b>&lt;3&gt;</b></tt></pre>
Junio C Hamano74e8a2d2006-01-14 03:58:41951</div></div>
Junio C Hamano68cf15a2010-11-06 01:01:59952<div class="colist arabic"><ol>
Junio C Hamanoc8d88c22006-04-29 07:02:01953<li>
954<p>
955This commit will get blown away so a throw-away log message is OK.
956</p>
957</li>
958<li>
959<p>
960This removes the <em>WIP</em> commit from the commit history, and sets
961 your working tree to the state just before you made that snapshot.
962</p>
963</li>
964<li>
965<p>
966At this point the index file still has all the WIP changes you
967 committed as <em>snapshot WIP</em>. This updates the index to show your
968 WIP files as uncommitted.
969</p>
Junio C Hamano68cf15a2010-11-06 01:01:59970<div class="paragraph"><p>See also <a href="git-stash.html">git-stash(1)</a>.</p></div>
Junio C Hamanoc8d88c22006-04-29 07:02:01971</li>
Junio C Hamanoba4b9282008-07-06 05:20:31972</ol></div>
Junio C Hamano74e8a2d2006-01-14 03:58:41973</dd>
Junio C Hamano68cf15a2010-11-06 01:01:59974<dt class="hdlist1">
Junio C Hamano26e590a2008-02-17 03:53:51975Reset a single file in the index
976</dt>
977<dd>
Junio C Hamano68cf15a2010-11-06 01:01:59978<div class="paragraph"><p>Suppose you have added a file to your index, but later decide you do not
Junio C Hamano26e590a2008-02-17 03:53:51979want to add it to your commit. You can remove the file from the index
Junio C Hamanoba4b9282008-07-06 05:20:31980while keeping your changes with git reset.</p></div>
Junio C Hamano26e590a2008-02-17 03:53:51981<div class="listingblock">
982<div class="content">
Junio C Hamano68cf15a2010-11-06 01:01:59983<pre><tt>$ git reset -- frotz.c <b>&lt;1&gt;</b>
984$ git commit -m "Commit files in index" <b>&lt;2&gt;</b>
985$ git add frotz.c <b>&lt;3&gt;</b></tt></pre>
Junio C Hamano26e590a2008-02-17 03:53:51986</div></div>
Junio C Hamano68cf15a2010-11-06 01:01:59987<div class="colist arabic"><ol>
Junio C Hamano26e590a2008-02-17 03:53:51988<li>
989<p>
990This removes the file from the index while keeping it in the working
991 directory.
992</p>
993</li>
994<li>
995<p>
996This commits all other changes in the index.
997</p>
998</li>
999<li>
1000<p>
1001Adds the file to the index again.
1002</p>
1003</li>
Junio C Hamanoba4b9282008-07-06 05:20:311004</ol></div>
Junio C Hamano26e590a2008-02-17 03:53:511005</dd>
Junio C Hamano68cf15a2010-11-06 01:01:591006<dt class="hdlist1">
Junio C Hamano0299d922010-03-20 20:59:311007Keep changes in working tree while discarding some previous commits
1008</dt>
1009<dd>
Junio C Hamano68cf15a2010-11-06 01:01:591010<div class="paragraph"><p>Suppose you are working on something and you commit it, and then you
Junio C Hamano0299d922010-03-20 20:59:311011continue working a bit more, but now you think that what you have in
1012your working tree should be in another branch that has nothing to do
Junio C Hamano619596a2010-08-18 22:15:351013with what you committed previously. You can start a new branch and
Junio C Hamano657fd8a2010-10-07 00:01:241014reset it while keeping the changes in your working tree.</p></div>
Junio C Hamano0299d922010-03-20 20:59:311015<div class="listingblock">
1016<div class="content">
1017<pre><tt>$ git tag start
1018$ git checkout -b branch1
1019$ edit
Junio C Hamano68cf15a2010-11-06 01:01:591020$ git commit ... <b>&lt;1&gt;</b>
Junio C Hamano0299d922010-03-20 20:59:311021$ edit
Junio C Hamano68cf15a2010-11-06 01:01:591022$ git checkout -b branch2 <b>&lt;2&gt;</b>
1023$ git reset --keep start <b>&lt;3&gt;</b></tt></pre>
Junio C Hamano0299d922010-03-20 20:59:311024</div></div>
Junio C Hamano68cf15a2010-11-06 01:01:591025<div class="colist arabic"><ol>
Junio C Hamano0299d922010-03-20 20:59:311026<li>
1027<p>
1028This commits your first edits in branch1.
1029</p>
1030</li>
1031<li>
1032<p>
1033In the ideal world, you could have realized that the earlier
1034 commit did not belong to the new topic when you created and switched
1035 to branch2 (i.e. "git checkout -b branch2 start"), but nobody is
1036 perfect.
1037</p>
1038</li>
1039<li>
1040<p>
1041But you can use "reset --keep" to remove the unwanted commit after
1042 you switched to "branch2".
1043</p>
1044</li>
1045</ol></div>
1046</dd>
Junio C Hamanoba4b9282008-07-06 05:20:311047</dl></div>
Junio C Hamano1a4e8412005-12-27 08:17:231048</div>
Junio C Hamanob5a296f2010-08-13 02:46:361049<h2 id="_discussion">DISCUSSION</h2>
1050<div class="sectionbody">
Junio C Hamano68cf15a2010-11-06 01:01:591051<div class="paragraph"><p>The tables below show what happens when running:</p></div>
Junio C Hamanob5a296f2010-08-13 02:46:361052<div class="listingblock">
1053<div class="content">
1054<pre><tt>git reset --option target</tt></pre>
1055</div></div>
Junio C Hamano68cf15a2010-11-06 01:01:591056<div class="paragraph"><p>to reset the HEAD to another commit (<tt>target</tt>) with the different
Junio C Hamanob5a296f2010-08-13 02:46:361057reset options depending on the state of the files.</p></div>
Junio C Hamano68cf15a2010-11-06 01:01:591058<div class="paragraph"><p>In these tables, A, B, C and D are some different states of a
Junio C Hamanob5a296f2010-08-13 02:46:361059file. For example, the first line of the first table means that if a
1060file is in state A in the working tree, in state B in the index, in
1061state C in HEAD and in state D in the target, then "git reset --soft
Junio C Hamano657fd8a2010-10-07 00:01:241062target" will leave the file in the working tree in state A and in the
1063index in state B. It resets (i.e. moves) the HEAD (i.e. the tip of
1064the current branch, if you are on one) to "target" (which has the file
1065in state D).</p></div>
Junio C Hamanob5a296f2010-08-13 02:46:361066<div class="literalblock">
1067<div class="content">
1068<pre><tt>working index HEAD target working index HEAD
1069----------------------------------------------------
1070 A B C D --soft A B D
1071 --mixed A D D
1072 --hard D D D
1073 --merge (disallowed)
1074 --keep (disallowed)</tt></pre>
1075</div></div>
1076<div class="literalblock">
1077<div class="content">
1078<pre><tt>working index HEAD target working index HEAD
1079----------------------------------------------------
1080 A B C C --soft A B C
1081 --mixed A C C
1082 --hard C C C
1083 --merge (disallowed)
1084 --keep A C C</tt></pre>
1085</div></div>
1086<div class="literalblock">
1087<div class="content">
1088<pre><tt>working index HEAD target working index HEAD
1089----------------------------------------------------
1090 B B C D --soft B B D
1091 --mixed B D D
1092 --hard D D D
1093 --merge D D D
1094 --keep (disallowed)</tt></pre>
1095</div></div>
1096<div class="literalblock">
1097<div class="content">
1098<pre><tt>working index HEAD target working index HEAD
1099----------------------------------------------------
1100 B B C C --soft B B C
1101 --mixed B C C
1102 --hard C C C
1103 --merge C C C
1104 --keep B C C</tt></pre>
1105</div></div>
1106<div class="literalblock">
1107<div class="content">
1108<pre><tt>working index HEAD target working index HEAD
1109----------------------------------------------------
1110 B C C D --soft B C D
1111 --mixed B D D
1112 --hard D D D
1113 --merge (disallowed)
1114 --keep (disallowed)</tt></pre>
1115</div></div>
1116<div class="literalblock">
1117<div class="content">
1118<pre><tt>working index HEAD target working index HEAD
1119----------------------------------------------------
1120 B C C C --soft B C C
1121 --mixed B C C
1122 --hard C C C
1123 --merge B C C
1124 --keep B C C</tt></pre>
1125</div></div>
Junio C Hamano68cf15a2010-11-06 01:01:591126<div class="paragraph"><p>"reset --merge" is meant to be used when resetting out of a conflicted
Junio C Hamano657fd8a2010-10-07 00:01:241127merge. Any mergy operation guarantees that the working tree file that is
Junio C Hamanob5a296f2010-08-13 02:46:361128involved in the merge does not have local change wrt the index before
Junio C Hamano657fd8a2010-10-07 00:01:241129it starts, and that it writes the result out to the working tree. So if
Junio C Hamanob5a296f2010-08-13 02:46:361130we see some difference between the index and the target and also
Junio C Hamano657fd8a2010-10-07 00:01:241131between the index and the working tree, then it means that we are not
Junio C Hamanob5a296f2010-08-13 02:46:361132resetting out from a state that a mergy operation left after failing
1133with a conflict. That is why we disallow --merge option in this case.</p></div>
Junio C Hamano68cf15a2010-11-06 01:01:591134<div class="paragraph"><p>"reset --keep" is meant to be used when removing some of the last
Junio C Hamanob5a296f2010-08-13 02:46:361135commits in the current branch while keeping changes in the working
1136tree. If there could be conflicts between the changes in the commit we
1137want to remove and the changes in the working tree we want to keep,
Junio C Hamano68cf15a2010-11-06 01:01:591138the reset is disallowed. That&#8217;s why it is disallowed if there are both
Junio C Hamanob5a296f2010-08-13 02:46:361139changes between the working tree and HEAD, and between HEAD and the
1140target. To be safe, it is also disallowed when there are unmerged
1141entries.</p></div>
Junio C Hamano68cf15a2010-11-06 01:01:591142<div class="paragraph"><p>The following tables show what happens when there are unmerged
Junio C Hamanob5a296f2010-08-13 02:46:361143entries:</p></div>
1144<div class="literalblock">
1145<div class="content">
1146<pre><tt>working index HEAD target working index HEAD
1147----------------------------------------------------
1148 X U A B --soft (disallowed)
1149 --mixed X B B
1150 --hard B B B
1151 --merge B B B
1152 --keep (disallowed)</tt></pre>
1153</div></div>
1154<div class="literalblock">
1155<div class="content">
1156<pre><tt>working index HEAD target working index HEAD
1157----------------------------------------------------
1158 X U A A --soft (disallowed)
1159 --mixed X A A
1160 --hard A A A
1161 --merge A A A
1162 --keep (disallowed)</tt></pre>
1163</div></div>
Junio C Hamano68cf15a2010-11-06 01:01:591164<div class="paragraph"><p>X means any state and U means an unmerged index.</p></div>
Junio C Hamanob5a296f2010-08-13 02:46:361165</div>
Junio C Hamanoba4b9282008-07-06 05:20:311166<h2 id="_git">GIT</h2>
Junio C Hamano1a4e8412005-12-27 08:17:231167<div class="sectionbody">
Junio C Hamano68cf15a2010-11-06 01:01:591168<div class="paragraph"><p>Part of the <a href="git.html">git(1)</a> suite</p></div>
Junio C Hamano1a4e8412005-12-27 08:17:231169</div>
Junio C Hamano7bd050f2011-09-22 06:32:221170</div>
1171<div id="footnotes"><hr /></div>
Junio C Hamano1a4e8412005-12-27 08:17:231172<div id="footer">
1173<div id="footer-text">
Junio C Hamanof0944d02011-11-30 20:46:291174Last updated 2011-11-30 12:46:15 PDT
Junio C Hamano1a4e8412005-12-27 08:17:231175</div>
1176</div>
1177</body>
1178</html>