blob: ddf80b7ca640857e20ffc202cb356133c3a2f27e [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>
Junio C Hamano9d971152012-12-19 00:43:115<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" />
Junio C Hamanoac12f0e2014-09-19 22:32:516<meta name="generator" content="AsciiDoc 8.6.9" />
Junio C Hamano68cf15a2010-11-06 01:01:597<title>git-rebase(1)</title>
Junio C Hamano1a4e8412005-12-27 08:17:238<style type="text/css">
Junio C Hamano9d971152012-12-19 00:43:119/* Shared CSS for AsciiDoc xhtml11 and html5 backends */
10
11/* Default font. */
12body {
13 font-family: Georgia,serif;
14}
15
16/* Title font. */
17h1, h2, h3, h4, h5, h6,
18div.title, caption.title,
19thead, p.table.header,
20#toctitle,
21#author, #revnumber, #revdate, #revremark,
22#footer {
23 font-family: Arial,Helvetica,sans-serif;
Junio C Hamano1a4e8412005-12-27 08:17:2324}
25
26body {
27 margin: 1em 5% 1em 5%;
28}
29
Junio C Hamanoba4b9282008-07-06 05:20:3130a {
31 color: blue;
32 text-decoration: underline;
33}
34a:visited {
35 color: fuchsia;
36}
Junio C Hamano1a4e8412005-12-27 08:17:2337
38em {
39 font-style: italic;
Junio C Hamano68cf15a2010-11-06 01:01:5940 color: navy;
Junio C Hamano1a4e8412005-12-27 08:17:2341}
42
43strong {
44 font-weight: bold;
Junio C Hamano68cf15a2010-11-06 01:01:5945 color: #083194;
Junio C Hamano1a4e8412005-12-27 08:17:2346}
47
Junio C Hamano1a4e8412005-12-27 08:17:2348h1, h2, h3, h4, h5, h6 {
49 color: #527bbd;
Junio C Hamano1a4e8412005-12-27 08:17:2350 margin-top: 1.2em;
51 margin-bottom: 0.5em;
52 line-height: 1.3;
53}
54
Junio C Hamanoba4b9282008-07-06 05:20:3155h1, h2, h3 {
Junio C Hamano1a4e8412005-12-27 08:17:2356 border-bottom: 2px solid silver;
57}
58h2 {
Junio C Hamano1a4e8412005-12-27 08:17:2359 padding-top: 0.5em;
60}
Junio C Hamanoba4b9282008-07-06 05:20:3161h3 {
62 float: left;
63}
64h3 + * {
65 clear: left;
66}
Junio C Hamano9d971152012-12-19 00:43:1167h5 {
68 font-size: 1.0em;
69}
Junio C Hamano1a4e8412005-12-27 08:17:2370
71div.sectionbody {
Junio C Hamano1a4e8412005-12-27 08:17:2372 margin-left: 0;
73}
74
75hr {
76 border: 1px solid silver;
77}
78
79p {
80 margin-top: 0.5em;
81 margin-bottom: 0.5em;
82}
83
Junio C Hamano68cf15a2010-11-06 01:01:5984ul, ol, li > p {
85 margin-top: 0;
86}
Junio C Hamano9d971152012-12-19 00:43:1187ul > li { color: #aaa; }
88ul > li > * { color: black; }
Junio C Hamano68cf15a2010-11-06 01:01:5989
Junio C Hamanoac12f0e2014-09-19 22:32:5190.monospaced, code, pre {
91 font-family: "Courier New", Courier, monospace;
92 font-size: inherit;
93 color: navy;
Junio C Hamano1a4e8412005-12-27 08:17:2394 padding: 0;
95 margin: 0;
96}
Junio C Hamanoac12f0e2014-09-19 22:32:5197pre {
98 white-space: pre-wrap;
99}
Junio C Hamano1a4e8412005-12-27 08:17:23100
Junio C Hamano9d971152012-12-19 00:43:11101#author {
Junio C Hamano1a4e8412005-12-27 08:17:23102 color: #527bbd;
Junio C Hamano1a4e8412005-12-27 08:17:23103 font-weight: bold;
Junio C Hamanoba4b9282008-07-06 05:20:31104 font-size: 1.1em;
Junio C Hamano1a4e8412005-12-27 08:17:23105}
Junio C Hamano9d971152012-12-19 00:43:11106#email {
Junio C Hamano1a4e8412005-12-27 08:17:23107}
Junio C Hamano9d971152012-12-19 00:43:11108#revnumber, #revdate, #revremark {
Junio C Hamano1a4e8412005-12-27 08:17:23109}
110
Junio C Hamano9d971152012-12-19 00:43:11111#footer {
Junio C Hamano1a4e8412005-12-27 08:17:23112 font-size: small;
113 border-top: 2px solid silver;
114 padding-top: 0.5em;
115 margin-top: 4.0em;
116}
Junio C Hamano9d971152012-12-19 00:43:11117#footer-text {
Junio C Hamano1a4e8412005-12-27 08:17:23118 float: left;
119 padding-bottom: 0.5em;
120}
Junio C Hamano9d971152012-12-19 00:43:11121#footer-badges {
Junio C Hamano1a4e8412005-12-27 08:17:23122 float: right;
123 padding-bottom: 0.5em;
124}
125
Junio C Hamano9d971152012-12-19 00:43:11126#preamble {
Junio C Hamano68cf15a2010-11-06 01:01:59127 margin-top: 1.5em;
128 margin-bottom: 1.5em;
129}
Junio C Hamano9d971152012-12-19 00:43:11130div.imageblock, div.exampleblock, div.verseblock,
Junio C Hamano1a4e8412005-12-27 08:17:23131div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock,
132div.admonitionblock {
Junio C Hamano7bd050f2011-09-22 06:32:22133 margin-top: 1.0em;
Junio C Hamano1a4e8412005-12-27 08:17:23134 margin-bottom: 1.5em;
135}
136div.admonitionblock {
Junio C Hamano7bd050f2011-09-22 06:32:22137 margin-top: 2.0em;
138 margin-bottom: 2.0em;
139 margin-right: 10%;
140 color: #606060;
Junio C Hamano1a4e8412005-12-27 08:17:23141}
142
143div.content { /* Block element content. */
144 padding: 0;
145}
146
147/* Block element titles. */
148div.title, caption.title {
Junio C Hamano68cf15a2010-11-06 01:01:59149 color: #527bbd;
Junio C Hamano1a4e8412005-12-27 08:17:23150 font-weight: bold;
151 text-align: left;
152 margin-top: 1.0em;
153 margin-bottom: 0.5em;
154}
155div.title + * {
156 margin-top: 0;
157}
158
159td div.title:first-child {
160 margin-top: 0.0em;
161}
162div.content div.title:first-child {
163 margin-top: 0.0em;
164}
165div.content + div.title {
166 margin-top: 0.0em;
167}
168
169div.sidebarblock > div.content {
170 background: #ffffee;
Junio C Hamano9d971152012-12-19 00:43:11171 border: 1px solid #dddddd;
172 border-left: 4px solid #f0f0f0;
Junio C Hamano1a4e8412005-12-27 08:17:23173 padding: 0.5em;
174}
175
176div.listingblock > div.content {
Junio C Hamano9d971152012-12-19 00:43:11177 border: 1px solid #dddddd;
178 border-left: 5px solid #f0f0f0;
179 background: #f8f8f8;
Junio C Hamano1a4e8412005-12-27 08:17:23180 padding: 0.5em;
181}
182
Junio C Hamano7bd050f2011-09-22 06:32:22183div.quoteblock, div.verseblock {
184 padding-left: 1.0em;
185 margin-left: 1.0em;
Junio C Hamano68cf15a2010-11-06 01:01:59186 margin-right: 10%;
Junio C Hamano9d971152012-12-19 00:43:11187 border-left: 5px solid #f0f0f0;
188 color: #888;
Junio C Hamano1a4e8412005-12-27 08:17:23189}
Junio C Hamano7bd050f2011-09-22 06:32:22190
Junio C Hamano68cf15a2010-11-06 01:01:59191div.quoteblock > div.attribution {
192 padding-top: 0.5em;
Junio C Hamano1a4e8412005-12-27 08:17:23193 text-align: right;
194}
Junio C Hamano68cf15a2010-11-06 01:01:59195
Junio C Hamano9d971152012-12-19 00:43:11196div.verseblock > pre.content {
197 font-family: inherit;
198 font-size: inherit;
Junio C Hamano68cf15a2010-11-06 01:01:59199}
200div.verseblock > div.attribution {
201 padding-top: 0.75em;
202 text-align: left;
203}
204/* DEPRECATED: Pre version 8.2.7 verse style literal block. */
Junio C Hamanoba4b9282008-07-06 05:20:31205div.verseblock + div.attribution {
206 text-align: left;
207}
Junio C Hamano1a4e8412005-12-27 08:17:23208
209div.admonitionblock .icon {
210 vertical-align: top;
211 font-size: 1.1em;
212 font-weight: bold;
213 text-decoration: underline;
214 color: #527bbd;
215 padding-right: 0.5em;
216}
217div.admonitionblock td.content {
218 padding-left: 0.5em;
Junio C Hamano7bd050f2011-09-22 06:32:22219 border-left: 3px solid #dddddd;
Junio C Hamano1a4e8412005-12-27 08:17:23220}
221
222div.exampleblock > div.content {
Junio C Hamano7bd050f2011-09-22 06:32:22223 border-left: 3px solid #dddddd;
224 padding-left: 0.5em;
Junio C Hamano1a4e8412005-12-27 08:17:23225}
226
Junio C Hamano1a4e8412005-12-27 08:17:23227div.imageblock div.content { padding-left: 0; }
Junio C Hamanoac12f0e2014-09-19 22:32:51228span.image img { border-style: none; vertical-align: text-bottom; }
Junio C Hamano68cf15a2010-11-06 01:01:59229a.image:visited { color: white; }
Junio C Hamano1a4e8412005-12-27 08:17:23230
231dl {
232 margin-top: 0.8em;
233 margin-bottom: 0.8em;
234}
235dt {
236 margin-top: 0.5em;
237 margin-bottom: 0;
Junio C Hamano68cf15a2010-11-06 01:01:59238 font-style: normal;
239 color: navy;
Junio C Hamano1a4e8412005-12-27 08:17:23240}
241dd > *:first-child {
Junio C Hamano68cf15a2010-11-06 01:01:59242 margin-top: 0.1em;
Junio C Hamano1a4e8412005-12-27 08:17:23243}
244
245ul, ol {
246 list-style-position: outside;
247}
Junio C Hamano68cf15a2010-11-06 01:01:59248ol.arabic {
249 list-style-type: decimal;
250}
251ol.loweralpha {
Junio C Hamano1a4e8412005-12-27 08:17:23252 list-style-type: lower-alpha;
253}
Junio C Hamano68cf15a2010-11-06 01:01:59254ol.upperalpha {
255 list-style-type: upper-alpha;
256}
257ol.lowerroman {
258 list-style-type: lower-roman;
259}
260ol.upperroman {
261 list-style-type: upper-roman;
262}
263
264div.compact ul, div.compact ol,
265div.compact p, div.compact p,
266div.compact div, div.compact div {
267 margin-top: 0.1em;
268 margin-bottom: 0.1em;
269}
Junio C Hamano1a4e8412005-12-27 08:17:23270
Junio C Hamano1a4e8412005-12-27 08:17:23271tfoot {
272 font-weight: bold;
273}
Junio C Hamano68cf15a2010-11-06 01:01:59274td > div.verse {
275 white-space: pre;
276}
Junio C Hamano68cf15a2010-11-06 01:01:59277
278div.hdlist {
Junio C Hamano1a4e8412005-12-27 08:17:23279 margin-top: 0.8em;
280 margin-bottom: 0.8em;
281}
Junio C Hamano68cf15a2010-11-06 01:01:59282div.hdlist tr {
283 padding-bottom: 15px;
Junio C Hamanoba4b9282008-07-06 05:20:31284}
Junio C Hamano68cf15a2010-11-06 01:01:59285dt.hdlist1.strong, td.hdlist1.strong {
286 font-weight: bold;
287}
288td.hdlist1 {
Junio C Hamano1a4e8412005-12-27 08:17:23289 vertical-align: top;
Junio C Hamano68cf15a2010-11-06 01:01:59290 font-style: normal;
Junio C Hamano1a4e8412005-12-27 08:17:23291 padding-right: 0.8em;
Junio C Hamano68cf15a2010-11-06 01:01:59292 color: navy;
Junio C Hamano1a4e8412005-12-27 08:17:23293}
Junio C Hamano68cf15a2010-11-06 01:01:59294td.hdlist2 {
Junio C Hamano1a4e8412005-12-27 08:17:23295 vertical-align: top;
296}
Junio C Hamano68cf15a2010-11-06 01:01:59297div.hdlist.compact tr {
298 margin: 0;
299 padding-bottom: 0;
300}
301
302.comment {
303 background: yellow;
304}
Junio C Hamano1a4e8412005-12-27 08:17:23305
Junio C Hamano7bd050f2011-09-22 06:32:22306.footnote, .footnoteref {
307 font-size: 0.8em;
308}
309
310span.footnote, span.footnoteref {
311 vertical-align: super;
312}
313
314#footnotes {
315 margin: 20px 0 20px 0;
316 padding: 7px 0 0 0;
317}
318
319#footnotes div.footnote {
320 margin: 0 0 5px 0;
321}
322
323#footnotes hr {
324 border: none;
325 border-top: 1px solid silver;
326 height: 1px;
327 text-align: left;
328 margin-left: 0;
329 width: 20%;
330 min-width: 100px;
331}
332
Junio C Hamano9d971152012-12-19 00:43:11333div.colist td {
334 padding-right: 0.5em;
335 padding-bottom: 0.3em;
336 vertical-align: top;
337}
338div.colist td img {
339 margin-top: 0.3em;
Junio C Hamano1a4e8412005-12-27 08:17:23340}
Junio C Hamanoba4b9282008-07-06 05:20:31341
Junio C Hamano9d971152012-12-19 00:43:11342@media print {
343 #footer-badges { display: none; }
344}
345
346#toc {
Junio C Hamano7bd050f2011-09-22 06:32:22347 margin-bottom: 2.5em;
348}
349
Junio C Hamano9d971152012-12-19 00:43:11350#toctitle {
Junio C Hamanoba4b9282008-07-06 05:20:31351 color: #527bbd;
Junio C Hamanoba4b9282008-07-06 05:20:31352 font-size: 1.1em;
353 font-weight: bold;
354 margin-top: 1.0em;
355 margin-bottom: 0.1em;
356}
357
Junio C Hamanoac12f0e2014-09-19 22:32:51358div.toclevel0, div.toclevel1, div.toclevel2, div.toclevel3, div.toclevel4 {
Junio C Hamanoba4b9282008-07-06 05:20:31359 margin-top: 0;
360 margin-bottom: 0;
361}
362div.toclevel2 {
363 margin-left: 2em;
364 font-size: 0.9em;
365}
366div.toclevel3 {
367 margin-left: 4em;
368 font-size: 0.9em;
369}
370div.toclevel4 {
371 margin-left: 6em;
372 font-size: 0.9em;
373}
Junio C Hamano9d971152012-12-19 00:43:11374
375span.aqua { color: aqua; }
376span.black { color: black; }
377span.blue { color: blue; }
378span.fuchsia { color: fuchsia; }
379span.gray { color: gray; }
380span.green { color: green; }
381span.lime { color: lime; }
382span.maroon { color: maroon; }
383span.navy { color: navy; }
384span.olive { color: olive; }
385span.purple { color: purple; }
386span.red { color: red; }
387span.silver { color: silver; }
388span.teal { color: teal; }
389span.white { color: white; }
390span.yellow { color: yellow; }
391
392span.aqua-background { background: aqua; }
393span.black-background { background: black; }
394span.blue-background { background: blue; }
395span.fuchsia-background { background: fuchsia; }
396span.gray-background { background: gray; }
397span.green-background { background: green; }
398span.lime-background { background: lime; }
399span.maroon-background { background: maroon; }
400span.navy-background { background: navy; }
401span.olive-background { background: olive; }
402span.purple-background { background: purple; }
403span.red-background { background: red; }
404span.silver-background { background: silver; }
405span.teal-background { background: teal; }
406span.white-background { background: white; }
407span.yellow-background { background: yellow; }
408
409span.big { font-size: 2em; }
410span.small { font-size: 0.6em; }
411
412span.underline { text-decoration: underline; }
413span.overline { text-decoration: overline; }
414span.line-through { text-decoration: line-through; }
415
Junio C Hamanoac12f0e2014-09-19 22:32:51416div.unbreakable { page-break-inside: avoid; }
417
Junio C Hamano9d971152012-12-19 00:43:11418
419/*
420 * xhtml11 specific
421 *
422 * */
423
424div.tableblock {
425 margin-top: 1.0em;
426 margin-bottom: 1.5em;
427}
428div.tableblock > table {
429 border: 3px solid #527bbd;
430}
431thead, p.table.header {
432 font-weight: bold;
433 color: #527bbd;
434}
435p.table {
436 margin-top: 0;
437}
438/* Because the table frame attribute is overriden by CSS in most browsers. */
439div.tableblock > table[frame="void"] {
440 border-style: none;
441}
442div.tableblock > table[frame="hsides"] {
443 border-left-style: none;
444 border-right-style: none;
445}
446div.tableblock > table[frame="vsides"] {
447 border-top-style: none;
448 border-bottom-style: none;
449}
450
451
452/*
453 * html5 specific
454 *
455 * */
456
457table.tableblock {
458 margin-top: 1.0em;
459 margin-bottom: 1.5em;
460}
461thead, p.tableblock.header {
462 font-weight: bold;
463 color: #527bbd;
464}
465p.tableblock {
466 margin-top: 0;
467}
468table.tableblock {
469 border-width: 3px;
470 border-spacing: 0px;
471 border-style: solid;
472 border-color: #527bbd;
473 border-collapse: collapse;
474}
475th.tableblock, td.tableblock {
476 border-width: 1px;
477 padding: 4px;
478 border-style: solid;
479 border-color: #527bbd;
480}
481
482table.tableblock.frame-topbot {
483 border-left-style: hidden;
484 border-right-style: hidden;
485}
486table.tableblock.frame-sides {
487 border-top-style: hidden;
488 border-bottom-style: hidden;
489}
490table.tableblock.frame-none {
491 border-style: hidden;
492}
493
494th.tableblock.halign-left, td.tableblock.halign-left {
495 text-align: left;
496}
497th.tableblock.halign-center, td.tableblock.halign-center {
498 text-align: center;
499}
500th.tableblock.halign-right, td.tableblock.halign-right {
501 text-align: right;
502}
503
504th.tableblock.valign-top, td.tableblock.valign-top {
505 vertical-align: top;
506}
507th.tableblock.valign-middle, td.tableblock.valign-middle {
508 vertical-align: middle;
509}
510th.tableblock.valign-bottom, td.tableblock.valign-bottom {
511 vertical-align: bottom;
512}
513
514
515/*
516 * manpage specific
517 *
518 * */
519
520body.manpage h1 {
Junio C Hamano68cf15a2010-11-06 01:01:59521 padding-top: 0.5em;
522 padding-bottom: 0.5em;
523 border-top: 2px solid silver;
524 border-bottom: 2px solid silver;
525}
Junio C Hamano9d971152012-12-19 00:43:11526body.manpage h2 {
Junio C Hamano68cf15a2010-11-06 01:01:59527 border-style: none;
528}
Junio C Hamano9d971152012-12-19 00:43:11529body.manpage div.sectionbody {
530 margin-left: 3em;
Junio C Hamano68cf15a2010-11-06 01:01:59531}
532
533@media print {
Junio C Hamano9d971152012-12-19 00:43:11534 body.manpage div#toc { display: none; }
Junio C Hamano68cf15a2010-11-06 01:01:59535}
Junio C Hamanoac12f0e2014-09-19 22:32:51536
537
Junio C Hamano1a4e8412005-12-27 08:17:23538</style>
Junio C Hamano7bd050f2011-09-22 06:32:22539<script type="text/javascript">
540/*<![CDATA[*/
Junio C Hamano7bd050f2011-09-22 06:32:22541var asciidoc = { // Namespace.
542
543/////////////////////////////////////////////////////////////////////
544// Table Of Contents generator
545/////////////////////////////////////////////////////////////////////
546
547/* Author: Mihai Bazon, September 2002
548 * http://students.infoiasi.ro/~mishoo
549 *
550 * Table Of Content generator
551 * Version: 0.4
552 *
553 * Feel free to use this script under the terms of the GNU General Public
554 * License, as long as you do not remove or alter this notice.
555 */
556
557 /* modified by Troy D. Hanson, September 2006. License: GPL */
558 /* modified by Stuart Rackham, 2006, 2009. License: GPL */
559
560// toclevels = 1..4.
561toc: function (toclevels) {
562
563 function getText(el) {
564 var text = "";
565 for (var i = el.firstChild; i != null; i = i.nextSibling) {
566 if (i.nodeType == 3 /* Node.TEXT_NODE */) // IE doesn't speak constants.
567 text += i.data;
568 else if (i.firstChild != null)
569 text += getText(i);
570 }
571 return text;
572 }
573
574 function TocEntry(el, text, toclevel) {
575 this.element = el;
576 this.text = text;
577 this.toclevel = toclevel;
578 }
579
580 function tocEntries(el, toclevels) {
581 var result = new Array;
Junio C Hamanoac12f0e2014-09-19 22:32:51582 var re = new RegExp('[hH]([1-'+(toclevels+1)+'])');
Junio C Hamano7bd050f2011-09-22 06:32:22583 // Function that scans the DOM tree for header elements (the DOM2
584 // nodeIterator API would be a better technique but not supported by all
585 // browsers).
586 var iterate = function (el) {
587 for (var i = el.firstChild; i != null; i = i.nextSibling) {
588 if (i.nodeType == 1 /* Node.ELEMENT_NODE */) {
589 var mo = re.exec(i.tagName);
590 if (mo && (i.getAttribute("class") || i.getAttribute("className")) != "float") {
591 result[result.length] = new TocEntry(i, getText(i), mo[1]-1);
592 }
593 iterate(i);
594 }
595 }
596 }
597 iterate(el);
598 return result;
599 }
600
601 var toc = document.getElementById("toc");
Junio C Hamano9d971152012-12-19 00:43:11602 if (!toc) {
603 return;
604 }
605
606 // Delete existing TOC entries in case we're reloading the TOC.
607 var tocEntriesToRemove = [];
608 var i;
609 for (i = 0; i < toc.childNodes.length; i++) {
610 var entry = toc.childNodes[i];
Junio C Hamanoac12f0e2014-09-19 22:32:51611 if (entry.nodeName.toLowerCase() == 'div'
Junio C Hamano9d971152012-12-19 00:43:11612 && entry.getAttribute("class")
613 && entry.getAttribute("class").match(/^toclevel/))
614 tocEntriesToRemove.push(entry);
615 }
616 for (i = 0; i < tocEntriesToRemove.length; i++) {
617 toc.removeChild(tocEntriesToRemove[i]);
618 }
619
620 // Rebuild TOC entries.
Junio C Hamano7bd050f2011-09-22 06:32:22621 var entries = tocEntries(document.getElementById("content"), toclevels);
622 for (var i = 0; i < entries.length; ++i) {
623 var entry = entries[i];
624 if (entry.element.id == "")
625 entry.element.id = "_toc_" + i;
626 var a = document.createElement("a");
627 a.href = "#" + entry.element.id;
628 a.appendChild(document.createTextNode(entry.text));
629 var div = document.createElement("div");
630 div.appendChild(a);
631 div.className = "toclevel" + entry.toclevel;
632 toc.appendChild(div);
633 }
634 if (entries.length == 0)
635 toc.parentNode.removeChild(toc);
636},
637
638
639/////////////////////////////////////////////////////////////////////
640// Footnotes generator
641/////////////////////////////////////////////////////////////////////
642
643/* Based on footnote generation code from:
644 * http://www.brandspankingnew.net/archive/2005/07/format_footnote.html
645 */
646
647footnotes: function () {
Junio C Hamano9d971152012-12-19 00:43:11648 // Delete existing footnote entries in case we're reloading the footnodes.
649 var i;
Junio C Hamano7bd050f2011-09-22 06:32:22650 var noteholder = document.getElementById("footnotes");
Junio C Hamano9d971152012-12-19 00:43:11651 if (!noteholder) {
652 return;
653 }
654 var entriesToRemove = [];
655 for (i = 0; i < noteholder.childNodes.length; i++) {
656 var entry = noteholder.childNodes[i];
Junio C Hamanoac12f0e2014-09-19 22:32:51657 if (entry.nodeName.toLowerCase() == 'div' && entry.getAttribute("class") == "footnote")
Junio C Hamano9d971152012-12-19 00:43:11658 entriesToRemove.push(entry);
659 }
660 for (i = 0; i < entriesToRemove.length; i++) {
661 noteholder.removeChild(entriesToRemove[i]);
662 }
663
664 // Rebuild footnote entries.
665 var cont = document.getElementById("content");
Junio C Hamano7bd050f2011-09-22 06:32:22666 var spans = cont.getElementsByTagName("span");
667 var refs = {};
668 var n = 0;
669 for (i=0; i<spans.length; i++) {
670 if (spans[i].className == "footnote") {
671 n++;
Junio C Hamano9d971152012-12-19 00:43:11672 var note = spans[i].getAttribute("data-note");
673 if (!note) {
674 // Use [\s\S] in place of . so multi-line matches work.
675 // Because JavaScript has no s (dotall) regex flag.
676 note = spans[i].innerHTML.match(/\s*\[([\s\S]*)]\s*/)[1];
677 spans[i].innerHTML =
678 "[<a id='_footnoteref_" + n + "' href='#_footnote_" + n +
679 "' title='View footnote' class='footnote'>" + n + "</a>]";
680 spans[i].setAttribute("data-note", note);
681 }
Junio C Hamano7bd050f2011-09-22 06:32:22682 noteholder.innerHTML +=
683 "<div class='footnote' id='_footnote_" + n + "'>" +
684 "<a href='#_footnoteref_" + n + "' title='Return to text'>" +
685 n + "</a>. " + note + "</div>";
Junio C Hamano7bd050f2011-09-22 06:32:22686 var id =spans[i].getAttribute("id");
687 if (id != null) refs["#"+id] = n;
688 }
689 }
690 if (n == 0)
691 noteholder.parentNode.removeChild(noteholder);
692 else {
693 // Process footnoterefs.
694 for (i=0; i<spans.length; i++) {
695 if (spans[i].className == "footnoteref") {
696 var href = spans[i].getElementsByTagName("a")[0].getAttribute("href");
697 href = href.match(/#.*/)[0]; // Because IE return full URL.
698 n = refs[href];
699 spans[i].innerHTML =
700 "[<a href='#_footnote_" + n +
701 "' title='View footnote' class='footnote'>" + n + "</a>]";
702 }
703 }
704 }
Junio C Hamano9d971152012-12-19 00:43:11705},
706
707install: function(toclevels) {
708 var timerId;
709
710 function reinstall() {
711 asciidoc.footnotes();
712 if (toclevels) {
713 asciidoc.toc(toclevels);
714 }
715 }
716
717 function reinstallAndRemoveTimer() {
718 clearInterval(timerId);
719 reinstall();
720 }
721
722 timerId = setInterval(reinstall, 500);
723 if (document.addEventListener)
724 document.addEventListener("DOMContentLoaded", reinstallAndRemoveTimer, false);
725 else
726 window.onload = reinstallAndRemoveTimer;
Junio C Hamano7bd050f2011-09-22 06:32:22727}
728
729}
Junio C Hamano9d971152012-12-19 00:43:11730asciidoc.install();
Junio C Hamano7bd050f2011-09-22 06:32:22731/*]]>*/
732</script>
Junio C Hamano1a4e8412005-12-27 08:17:23733</head>
Junio C Hamano9d971152012-12-19 00:43:11734<body class="manpage">
Junio C Hamano1a4e8412005-12-27 08:17:23735<div id="header">
736<h1>
737git-rebase(1) Manual Page
738</h1>
739<h2>NAME</h2>
740<div class="sectionbody">
741<p>git-rebase -
Junio C Hamano7c73c662007-01-19 00:37:50742 Forward-port local commits to the updated upstream head
Junio C Hamano1a4e8412005-12-27 08:17:23743</p>
744</div>
745</div>
Junio C Hamano7bd050f2011-09-22 06:32:22746<div id="content">
Junio C Hamano9d971152012-12-19 00:43:11747<div class="sect1">
Junio C Hamano68cf15a2010-11-06 01:01:59748<h2 id="_synopsis">SYNOPSIS</h2>
Junio C Hamano1a4e8412005-12-27 08:17:23749<div class="sectionbody">
Junio C Hamanoa9b8d242007-05-19 04:51:55750<div class="verseblock">
Junio C Hamano9d971152012-12-19 00:43:11751<pre class="content"><em>git rebase</em> [-i | --interactive] [options] [--exec &lt;cmd&gt;] [--onto &lt;newbase&gt;]
Junio C Hamanoac12f0e2014-09-19 22:32:51752 [&lt;upstream&gt; [&lt;branch&gt;]]
Junio C Hamano02482692012-07-16 05:28:39753<em>git rebase</em> [-i | --interactive] [options] [--exec &lt;cmd&gt;] [--onto &lt;newbase&gt;]
Junio C Hamano15567bc2011-07-23 00:51:59754 --root [&lt;branch&gt;]
Junio C Hamano9d971152012-12-19 00:43:11755<em>git rebase</em> --continue | --skip | --abort | --edit-todo</pre>
756<div class="attribution">
Junio C Hamano68cf15a2010-11-06 01:01:59757</div></div>
Junio C Hamano1a4e8412005-12-27 08:17:23758</div>
Junio C Hamano9d971152012-12-19 00:43:11759</div>
760<div class="sect1">
Junio C Hamanoba4b9282008-07-06 05:20:31761<h2 id="_description">DESCRIPTION</h2>
Junio C Hamano1a4e8412005-12-27 08:17:23762<div class="sectionbody">
Junio C Hamano68cf15a2010-11-06 01:01:59763<div class="paragraph"><p>If &lt;branch&gt; is specified, <em>git rebase</em> will perform an automatic
Junio C Hamanoac12f0e2014-09-19 22:32:51764<code>git checkout &lt;branch&gt;</code> before doing anything else. Otherwise
Junio C Hamanoba4b9282008-07-06 05:20:31765it remains on the current branch.</p></div>
Junio C Hamanob02377c2011-04-28 22:26:02766<div class="paragraph"><p>If &lt;upstream&gt; is not specified, the upstream configured in
Junio C Hamano9236fea2014-10-14 22:28:09767branch.&lt;name&gt;.remote and branch.&lt;name&gt;.merge options will be used (see
768<a href="git-config.html">git-config(1)</a> for details) and the <code>--fork-point</code> option is
769assumed. If you are currently not on any branch or if the current
770branch does not have a configured upstream, the rebase will abort.</p></div>
Junio C Hamano68cf15a2010-11-06 01:01:59771<div class="paragraph"><p>All changes made by commits in the current branch but that are not
Junio C Hamano89d4e0f2007-02-18 00:34:59772in &lt;upstream&gt; are saved to a temporary area. This is the same set
Junio C Hamano9236fea2014-10-14 22:28:09773of commits that would be shown by <code>git log &lt;upstream&gt;..HEAD</code>; or by
774<code>git log 'fork_point'..HEAD</code>, if <code>--fork-point</code> is active (see the
775description on <code>--fork-point</code> below); or by <code>git log HEAD</code>, if the
776<code>--root</code> option is specified.</p></div>
Junio C Hamano68cf15a2010-11-06 01:01:59777<div class="paragraph"><p>The current branch is reset to &lt;upstream&gt;, or &lt;newbase&gt; if the
Junio C Hamano89d4e0f2007-02-18 00:34:59778--onto option was supplied. This has the exact same effect as
Junio C Hamanoac12f0e2014-09-19 22:32:51779<code>git reset --hard &lt;upstream&gt;</code> (or &lt;newbase&gt;). ORIG_HEAD is set
Junio C Hamano38ddcce2008-07-15 15:49:03780to point at the tip of the branch before the reset.</p></div>
Junio C Hamano68cf15a2010-11-06 01:01:59781<div class="paragraph"><p>The commits that were previously saved into the temporary area are
Junio C Hamano764a6672007-10-23 01:23:31782then reapplied to the current branch, one by one, in order. Note that
783any commits in HEAD which introduce the same textual changes as a commit
784in HEAD..&lt;upstream&gt; are omitted (i.e., a patch already accepted upstream
Junio C Hamanoba4b9282008-07-06 05:20:31785with a different commit message or timestamp will be skipped).</p></div>
Junio C Hamano68cf15a2010-11-06 01:01:59786<div class="paragraph"><p>It is possible that a merge failure will prevent this process from being
Junio C Hamano6112cad2006-05-02 07:28:06787completely automatic. You will have to resolve any such merge failure
Junio C Hamanoac12f0e2014-09-19 22:32:51788and run <code>git rebase --continue</code>. Another option is to bypass the commit
789that caused the merge failure with <code>git rebase --skip</code>. To check out the
Junio C Hamano0868a302008-07-22 09:20:44790original &lt;branch&gt; and remove the .git/rebase-apply working files, use the
Junio C Hamanoac12f0e2014-09-19 22:32:51791command <code>git rebase --abort</code> instead.</p></div>
Junio C Hamano68cf15a2010-11-06 01:01:59792<div class="paragraph"><p>Assume the following history exists and the current branch is "topic":</p></div>
Junio C Hamano6112cad2006-05-02 07:28:06793<div class="listingblock">
Junio C Hamano7e9f6b72006-02-22 10:44:55794<div class="content">
Junio C Hamanoac12f0e2014-09-19 22:32:51795<pre><code> A---B---C topic
Junio C Hamano6112cad2006-05-02 07:28:06796 /
Junio C Hamanoac12f0e2014-09-19 22:32:51797 D---E---F---G master</code></pre>
Junio C Hamano7e9f6b72006-02-22 10:44:55798</div></div>
Junio C Hamano68cf15a2010-11-06 01:01:59799<div class="paragraph"><p>From this point, the result of either of the following commands:</p></div>
Junio C Hamano7e9f6b72006-02-22 10:44:55800<div class="literalblock">
801<div class="content">
Junio C Hamanoac12f0e2014-09-19 22:32:51802<pre><code>git rebase master
803git rebase master topic</code></pre>
Junio C Hamano7e9f6b72006-02-22 10:44:55804</div></div>
Junio C Hamano68cf15a2010-11-06 01:01:59805<div class="paragraph"><p>would be:</p></div>
Junio C Hamano6112cad2006-05-02 07:28:06806<div class="listingblock">
Junio C Hamano7e9f6b72006-02-22 10:44:55807<div class="content">
Junio C Hamanoac12f0e2014-09-19 22:32:51808<pre><code> A'--B'--C' topic
Junio C Hamano6112cad2006-05-02 07:28:06809 /
Junio C Hamanoac12f0e2014-09-19 22:32:51810 D---E---F---G master</code></pre>
Junio C Hamano7e9f6b72006-02-22 10:44:55811</div></div>
Junio C Hamanoac12f0e2014-09-19 22:32:51812<div class="paragraph"><p><strong>NOTE:</strong> The latter form is just a short-hand of <code>git checkout topic</code>
813followed by <code>git rebase master</code>. When rebase exits <code>topic</code> will
Junio C Hamano92faa802011-03-15 01:00:18814remain the checked-out branch.</p></div>
Junio C Hamano68cf15a2010-11-06 01:01:59815<div class="paragraph"><p>If the upstream branch already contains a change you have made (e.g.,
Junio C Hamano764a6672007-10-23 01:23:31816because you mailed a patch which was applied upstream), then that commit
Junio C Hamano1dbca522015-05-22 20:48:55817will be skipped. For example, running <code>git rebase master</code> on the
818following history (in which <code>A'</code> and <code>A</code> introduce the same set of changes,
Junio C Hamanoba4b9282008-07-06 05:20:31819but have different committer information):</p></div>
Junio C Hamano764a6672007-10-23 01:23:31820<div class="listingblock">
821<div class="content">
Junio C Hamanoac12f0e2014-09-19 22:32:51822<pre><code> A---B---C topic
Junio C Hamano764a6672007-10-23 01:23:31823 /
Junio C Hamanoac12f0e2014-09-19 22:32:51824 D---E---A'---F master</code></pre>
Junio C Hamano764a6672007-10-23 01:23:31825</div></div>
Junio C Hamano68cf15a2010-11-06 01:01:59826<div class="paragraph"><p>will result in:</p></div>
Junio C Hamano764a6672007-10-23 01:23:31827<div class="listingblock">
828<div class="content">
Junio C Hamanoac12f0e2014-09-19 22:32:51829<pre><code> B'---C' topic
Junio C Hamano764a6672007-10-23 01:23:31830 /
Junio C Hamanoac12f0e2014-09-19 22:32:51831 D---E---A'---F master</code></pre>
Junio C Hamano764a6672007-10-23 01:23:31832</div></div>
Junio C Hamano68cf15a2010-11-06 01:01:59833<div class="paragraph"><p>Here is how you would transplant a topic branch based on one
Junio C Hamanod8c9d432006-11-07 07:19:13834branch to another, to pretend that you forked the topic branch
Junio C Hamanoac12f0e2014-09-19 22:32:51835from the latter branch, using <code>rebase --onto</code>.</p></div>
Junio C Hamano68cf15a2010-11-06 01:01:59836<div class="paragraph"><p>First let&#8217;s assume your <em>topic</em> is based on branch <em>next</em>.
Junio C Hamanoa476efa2008-10-10 15:31:42837For example, a feature developed in <em>topic</em> depends on some
Junio C Hamanoba4b9282008-07-06 05:20:31838functionality which is found in <em>next</em>.</p></div>
Junio C Hamano6112cad2006-05-02 07:28:06839<div class="listingblock">
Junio C Hamano7e9f6b72006-02-22 10:44:55840<div class="content">
Junio C Hamanoac12f0e2014-09-19 22:32:51841<pre><code> o---o---o---o---o master
Junio C Hamanod8c9d432006-11-07 07:19:13842 \
843 o---o---o---o---o next
844 \
Junio C Hamanoac12f0e2014-09-19 22:32:51845 o---o---o topic</code></pre>
Junio C Hamano7e9f6b72006-02-22 10:44:55846</div></div>
Junio C Hamano68cf15a2010-11-06 01:01:59847<div class="paragraph"><p>We want to make <em>topic</em> forked from branch <em>master</em>; for example,
Junio C Hamanoa476efa2008-10-10 15:31:42848because the functionality on which <em>topic</em> depends was merged into the
849more stable <em>master</em> branch. We want our tree to look like this:</p></div>
Junio C Hamanod8c9d432006-11-07 07:19:13850<div class="listingblock">
851<div class="content">
Junio C Hamanoac12f0e2014-09-19 22:32:51852<pre><code> o---o---o---o---o master
Junio C Hamanod8c9d432006-11-07 07:19:13853 | \
854 | o'--o'--o' topic
855 \
Junio C Hamanoac12f0e2014-09-19 22:32:51856 o---o---o---o---o next</code></pre>
Junio C Hamanod8c9d432006-11-07 07:19:13857</div></div>
Junio C Hamano68cf15a2010-11-06 01:01:59858<div class="paragraph"><p>We can get this using the following command:</p></div>
Junio C Hamanod8c9d432006-11-07 07:19:13859<div class="literalblock">
860<div class="content">
Junio C Hamanoac12f0e2014-09-19 22:32:51861<pre><code>git rebase --onto master next topic</code></pre>
Junio C Hamanod8c9d432006-11-07 07:19:13862</div></div>
Junio C Hamano68cf15a2010-11-06 01:01:59863<div class="paragraph"><p>Another example of --onto option is to rebase part of a
Junio C Hamanoba4b9282008-07-06 05:20:31864branch. If we have the following situation:</p></div>
Junio C Hamanod8c9d432006-11-07 07:19:13865<div class="listingblock">
866<div class="content">
Junio C Hamanoac12f0e2014-09-19 22:32:51867<pre><code> H---I---J topicB
Junio C Hamanod8c9d432006-11-07 07:19:13868 /
869 E---F---G topicA
870 /
Junio C Hamanoac12f0e2014-09-19 22:32:51871 A---B---C---D master</code></pre>
Junio C Hamanod8c9d432006-11-07 07:19:13872</div></div>
Junio C Hamano68cf15a2010-11-06 01:01:59873<div class="paragraph"><p>then the command</p></div>
Junio C Hamanod8c9d432006-11-07 07:19:13874<div class="literalblock">
875<div class="content">
Junio C Hamanoac12f0e2014-09-19 22:32:51876<pre><code>git rebase --onto master topicA topicB</code></pre>
Junio C Hamanod8c9d432006-11-07 07:19:13877</div></div>
Junio C Hamano68cf15a2010-11-06 01:01:59878<div class="paragraph"><p>would result in:</p></div>
Junio C Hamanod8c9d432006-11-07 07:19:13879<div class="listingblock">
880<div class="content">
Junio C Hamanoac12f0e2014-09-19 22:32:51881<pre><code> H'--I'--J' topicB
Junio C Hamanod8c9d432006-11-07 07:19:13882 /
883 | E---F---G topicA
884 |/
Junio C Hamanoac12f0e2014-09-19 22:32:51885 A---B---C---D master</code></pre>
Junio C Hamanod8c9d432006-11-07 07:19:13886</div></div>
Junio C Hamano68cf15a2010-11-06 01:01:59887<div class="paragraph"><p>This is useful when topicB does not depend on topicA.</p></div>
888<div class="paragraph"><p>A range of commits could also be removed with rebase. If we have
Junio C Hamanoba4b9282008-07-06 05:20:31889the following situation:</p></div>
Junio C Hamano42f855f2007-02-06 00:09:38890<div class="listingblock">
891<div class="content">
Junio C Hamanoac12f0e2014-09-19 22:32:51892<pre><code> E---F---G---H---I---J topicA</code></pre>
Junio C Hamano42f855f2007-02-06 00:09:38893</div></div>
Junio C Hamano68cf15a2010-11-06 01:01:59894<div class="paragraph"><p>then the command</p></div>
Junio C Hamano42f855f2007-02-06 00:09:38895<div class="literalblock">
896<div class="content">
Junio C Hamanoac12f0e2014-09-19 22:32:51897<pre><code>git rebase --onto topicA~5 topicA~3 topicA</code></pre>
Junio C Hamano42f855f2007-02-06 00:09:38898</div></div>
Junio C Hamano68cf15a2010-11-06 01:01:59899<div class="paragraph"><p>would result in the removal of commits F and G:</p></div>
Junio C Hamano42f855f2007-02-06 00:09:38900<div class="listingblock">
901<div class="content">
Junio C Hamanoac12f0e2014-09-19 22:32:51902<pre><code> E---H'---I'---J' topicA</code></pre>
Junio C Hamano42f855f2007-02-06 00:09:38903</div></div>
Junio C Hamano68cf15a2010-11-06 01:01:59904<div class="paragraph"><p>This is useful if F and G were flawed in some way, or should not be
Junio C Hamano42f855f2007-02-06 00:09:38905part of topicA. Note that the argument to --onto and the &lt;upstream&gt;
Junio C Hamanoba4b9282008-07-06 05:20:31906parameter can be any valid commit-ish.</p></div>
Junio C Hamano68cf15a2010-11-06 01:01:59907<div class="paragraph"><p>In case of conflict, <em>git rebase</em> will stop at the first problematic commit
Junio C Hamano1aa40d22010-01-21 17:46:43908and leave conflict markers in the tree. You can use <em>git diff</em> to locate
Junio C Hamano6112cad2006-05-02 07:28:06909the markers (&lt;&lt;&lt;&lt;&lt;&lt;) and make edits to resolve the conflict. For each
Junio C Hamano076ffcc2013-02-06 05:13:21910file you edit, you need to tell Git that the conflict has been resolved,
Junio C Hamanoba4b9282008-07-06 05:20:31911typically this would be done with</p></div>
Junio C Hamanof02e09f2006-03-27 07:51:03912<div class="literalblock">
913<div class="content">
Junio C Hamanoac12f0e2014-09-19 22:32:51914<pre><code>git add &lt;filename&gt;</code></pre>
Junio C Hamano6112cad2006-05-02 07:28:06915</div></div>
Junio C Hamano68cf15a2010-11-06 01:01:59916<div class="paragraph"><p>After resolving the conflict manually and updating the index with the
Junio C Hamanoba4b9282008-07-06 05:20:31917desired resolution, you can continue the rebasing process with</p></div>
Junio C Hamano6112cad2006-05-02 07:28:06918<div class="literalblock">
919<div class="content">
Junio C Hamanoac12f0e2014-09-19 22:32:51920<pre><code>git rebase --continue</code></pre>
Junio C Hamanof02e09f2006-03-27 07:51:03921</div></div>
Junio C Hamano68cf15a2010-11-06 01:01:59922<div class="paragraph"><p>Alternatively, you can undo the <em>git rebase</em> with</p></div>
Junio C Hamanof02e09f2006-03-27 07:51:03923<div class="literalblock">
924<div class="content">
Junio C Hamanoac12f0e2014-09-19 22:32:51925<pre><code>git rebase --abort</code></pre>
Junio C Hamanof02e09f2006-03-27 07:51:03926</div></div>
Junio C Hamano1a4e8412005-12-27 08:17:23927</div>
Junio C Hamano9d971152012-12-19 00:43:11928</div>
929<div class="sect1">
Junio C Hamanoea6a7642009-03-11 23:56:19930<h2 id="_configuration">CONFIGURATION</h2>
931<div class="sectionbody">
Junio C Hamano68cf15a2010-11-06 01:01:59932<div class="dlist"><dl>
933<dt class="hdlist1">
Junio C Hamanoea6a7642009-03-11 23:56:19934rebase.stat
935</dt>
936<dd>
937<p>
938 Whether to show a diffstat of what changed upstream since the last
939 rebase. False by default.
940</p>
941</dd>
Junio C Hamano68cf15a2010-11-06 01:01:59942<dt class="hdlist1">
Junio C Hamano322c6242015-03-23 21:32:46943rebase.autoSquash
Junio C Hamano075ae872010-09-01 18:43:07944</dt>
945<dd>
946<p>
947 If set to true enable <em>--autosquash</em> option by default.
948</p>
949</dd>
Junio C Hamanof1f5a7b2013-06-11 22:23:52950<dt class="hdlist1">
Junio C Hamano322c6242015-03-23 21:32:46951rebase.autoStash
Junio C Hamanof1f5a7b2013-06-11 22:23:52952</dt>
953<dd>
954<p>
955 If set to true enable <em>--autostash</em> option by default.
956</p>
957</dd>
Junio C Hamanod7ed4042015-08-03 19:43:00958<dt class="hdlist1">
959rebase.missingCommitsCheck
960</dt>
961<dd>
962<p>
963 If set to "warn", print warnings about removed commits in
964 interactive mode. If set to "error", print the warnings and
965 stop the rebase. If set to "ignore", no checking is
966 done. "ignore" by default.
967</p>
968</dd>
969<dt class="hdlist1">
970rebase.instructionFormat
971</dt>
972<dd>
973<p>
974 Custom commit list format to use during an <em>--interactive</em> rebase.
975</p>
976</dd>
Junio C Hamanoea6a7642009-03-11 23:56:19977</dl></div>
978</div>
Junio C Hamano9d971152012-12-19 00:43:11979</div>
980<div class="sect1">
Junio C Hamanoba4b9282008-07-06 05:20:31981<h2 id="_options">OPTIONS</h2>
Junio C Hamano1a4e8412005-12-27 08:17:23982<div class="sectionbody">
Junio C Hamano68cf15a2010-11-06 01:01:59983<div class="dlist"><dl>
984<dt class="hdlist1">
Junio C Hamano644936c2012-06-28 23:05:14985--onto &lt;newbase&gt;
Junio C Hamano7e9f6b72006-02-22 10:44:55986</dt>
987<dd>
988<p>
989 Starting point at which to create the new commits. If the
990 --onto option is not specified, the starting point is
Junio C Hamano42f855f2007-02-06 00:09:38991 &lt;upstream&gt;. May be any valid commit, and not just an
992 existing branch name.
Junio C Hamano7e9f6b72006-02-22 10:44:55993</p>
Junio C Hamano68cf15a2010-11-06 01:01:59994<div class="paragraph"><p>As a special case, you may use "A...B" as a shortcut for the
Junio C Hamanoe32ec8b2010-06-02 23:32:31995merge base of A and B if there is exactly one merge base. You can
996leave out at most one of A and B, in which case it defaults to HEAD.</p></div>
Junio C Hamano7e9f6b72006-02-22 10:44:55997</dd>
Junio C Hamano68cf15a2010-11-06 01:01:59998<dt class="hdlist1">
Junio C Hamano1a4e8412005-12-27 08:17:23999&lt;upstream&gt;
1000</dt>
1001<dd>
1002<p>
Junio C Hamano42f855f2007-02-06 00:09:381003 Upstream branch to compare against. May be any valid commit,
Junio C Hamanob02377c2011-04-28 22:26:021004 not just an existing branch name. Defaults to the configured
1005 upstream for the current branch.
Junio C Hamano1a4e8412005-12-27 08:17:231006</p>
1007</dd>
Junio C Hamano68cf15a2010-11-06 01:01:591008<dt class="hdlist1">
Junio C Hamano2b135272006-03-18 07:45:421009&lt;branch&gt;
Junio C Hamano1a4e8412005-12-27 08:17:231010</dt>
1011<dd>
1012<p>
1013 Working branch; defaults to HEAD.
1014</p>
1015</dd>
Junio C Hamano68cf15a2010-11-06 01:01:591016<dt class="hdlist1">
Junio C Hamano6112cad2006-05-02 07:28:061017--continue
1018</dt>
1019<dd>
1020<p>
1021 Restart the rebasing process after having resolved a merge conflict.
1022</p>
1023</dd>
Junio C Hamano68cf15a2010-11-06 01:01:591024<dt class="hdlist1">
Junio C Hamano6112cad2006-05-02 07:28:061025--abort
1026</dt>
1027<dd>
1028<p>
Junio C Hamano15567bc2011-07-23 00:51:591029 Abort the rebase operation and reset HEAD to the original
1030 branch. If &lt;branch&gt; was provided when the rebase operation was
1031 started, then HEAD will be reset to &lt;branch&gt;. Otherwise HEAD
1032 will be reset to where it was when the rebase operation was
1033 started.
Junio C Hamano6112cad2006-05-02 07:28:061034</p>
1035</dd>
Junio C Hamano68cf15a2010-11-06 01:01:591036<dt class="hdlist1">
Junio C Hamano37e389e2012-04-30 22:36:091037--keep-empty
1038</dt>
1039<dd>
1040<p>
1041 Keep the commits that do not change anything from its
1042 parents in the result.
1043</p>
1044</dd>
1045<dt class="hdlist1">
Junio C Hamano97f518c2006-06-22 19:49:351046--skip
1047</dt>
1048<dd>
1049<p>
1050 Restart the rebasing process by skipping the current patch.
Junio C Hamano97f518c2006-06-22 19:49:351051</p>
1052</dd>
Junio C Hamano68cf15a2010-11-06 01:01:591053<dt class="hdlist1">
Junio C Hamano9cdfecf2012-09-30 07:38:361054--edit-todo
1055</dt>
1056<dd>
1057<p>
1058 Edit the todo list during an interactive rebase.
1059</p>
1060</dd>
1061<dt class="hdlist1">
Junio C Hamanoeb415992008-06-08 22:49:471062-m
1063</dt>
Junio C Hamano68cf15a2010-11-06 01:01:591064<dt class="hdlist1">
Junio C Hamanoeb415992008-06-08 22:49:471065--merge
Junio C Hamano97f518c2006-06-22 19:49:351066</dt>
1067<dd>
1068<p>
1069 Use merging strategies to rebase. When the recursive (default) merge
1070 strategy is used, this allows rebase to be aware of renames on the
1071 upstream side.
1072</p>
Junio C Hamano68cf15a2010-11-06 01:01:591073<div class="paragraph"><p>Note that a rebase merge works by replaying each commit from the working
Junio C Hamanobf984de2009-11-23 06:11:191074branch on top of the &lt;upstream&gt; branch. Because of this, when a merge
1075conflict happens, the side reported as <em>ours</em> is the so-far rebased
1076series, starting with &lt;upstream&gt;, and <em>theirs</em> is the working branch. In
1077other words, the sides are swapped.</p></div>
Junio C Hamano97f518c2006-06-22 19:49:351078</dd>
Junio C Hamano68cf15a2010-11-06 01:01:591079<dt class="hdlist1">
Junio C Hamanoeb415992008-06-08 22:49:471080-s &lt;strategy&gt;
1081</dt>
Junio C Hamano68cf15a2010-11-06 01:01:591082<dt class="hdlist1">
Junio C Hamanoeb415992008-06-08 22:49:471083--strategy=&lt;strategy&gt;
Junio C Hamano97f518c2006-06-22 19:49:351084</dt>
1085<dd>
1086<p>
Junio C Hamano52d5def2009-05-21 16:27:431087 Use the given merge strategy.
Junio C Hamanoac12f0e2014-09-19 22:32:511088 If there is no <code>-s</code> option <em>git merge-recursive</em> is used
Junio C Hamanobf984de2009-11-23 06:11:191089 instead. This implies --merge.
Junio C Hamano97f518c2006-06-22 19:49:351090</p>
Junio C Hamano68cf15a2010-11-06 01:01:591091<div class="paragraph"><p>Because <em>git rebase</em> replays each commit from the working branch
Junio C Hamanobf984de2009-11-23 06:11:191092on top of the &lt;upstream&gt; branch using the given strategy, using
1093the <em>ours</em> strategy simply discards all patches from the &lt;branch&gt;,
1094which makes little sense.</p></div>
Junio C Hamano97f518c2006-06-22 19:49:351095</dd>
Junio C Hamano68cf15a2010-11-06 01:01:591096<dt class="hdlist1">
Junio C Hamano619596a2010-08-18 22:15:351097-X &lt;strategy-option&gt;
1098</dt>
Junio C Hamano68cf15a2010-11-06 01:01:591099<dt class="hdlist1">
Junio C Hamano619596a2010-08-18 22:15:351100--strategy-option=&lt;strategy-option&gt;
1101</dt>
1102<dd>
1103<p>
1104 Pass the &lt;strategy-option&gt; through to the merge strategy.
Junio C Hamanoac12f0e2014-09-19 22:32:511105 This implies <code>--merge</code> and, if no strategy has been
1106 specified, <code>-s recursive</code>. Note the reversal of <em>ours</em> and
1107 <em>theirs</em> as noted above for the <code>-m</code> option.
Junio C Hamano619596a2010-08-18 22:15:351108</p>
1109</dd>
Junio C Hamano68cf15a2010-11-06 01:01:591110<dt class="hdlist1">
Junio C Hamano5b3533d2014-02-27 23:07:151111-S[&lt;keyid&gt;]
1112</dt>
1113<dt class="hdlist1">
1114--gpg-sign[=&lt;keyid&gt;]
1115</dt>
1116<dd>
1117<p>
Junio C Hamano1eb56092015-10-05 20:39:531118 GPG-sign commits. The <code>keyid</code> argument is optional and
1119 defaults to the committer identity; if specified, it must be
1120 stuck to the option without a space.
Junio C Hamano5b3533d2014-02-27 23:07:151121</p>
1122</dd>
1123<dt class="hdlist1">
Junio C Hamano2c14c8d2009-07-02 03:17:001124-q
1125</dt>
Junio C Hamano68cf15a2010-11-06 01:01:591126<dt class="hdlist1">
Junio C Hamano2c14c8d2009-07-02 03:17:001127--quiet
1128</dt>
1129<dd>
1130<p>
1131 Be quiet. Implies --no-stat.
1132</p>
1133</dd>
Junio C Hamano68cf15a2010-11-06 01:01:591134<dt class="hdlist1">
Junio C Hamanoeb415992008-06-08 22:49:471135-v
1136</dt>
Junio C Hamano68cf15a2010-11-06 01:01:591137<dt class="hdlist1">
Junio C Hamanoeb415992008-06-08 22:49:471138--verbose
Junio C Hamanofbe00522006-10-19 05:58:481139</dt>
1140<dd>
1141<p>
Junio C Hamanoea6a7642009-03-11 23:56:191142 Be verbose. Implies --stat.
1143</p>
1144</dd>
Junio C Hamano68cf15a2010-11-06 01:01:591145<dt class="hdlist1">
Junio C Hamanoea6a7642009-03-11 23:56:191146--stat
1147</dt>
1148<dd>
1149<p>
1150 Show a diffstat of what changed upstream since the last rebase. The
1151 diffstat is also controlled by the configuration option rebase.stat.
1152</p>
1153</dd>
Junio C Hamano68cf15a2010-11-06 01:01:591154<dt class="hdlist1">
Junio C Hamanoea6a7642009-03-11 23:56:191155-n
1156</dt>
Junio C Hamano68cf15a2010-11-06 01:01:591157<dt class="hdlist1">
Junio C Hamanoea6a7642009-03-11 23:56:191158--no-stat
1159</dt>
1160<dd>
1161<p>
1162 Do not show a diffstat as part of the rebase process.
Junio C Hamanofbe00522006-10-19 05:58:481163</p>
1164</dd>
Junio C Hamano68cf15a2010-11-06 01:01:591165<dt class="hdlist1">
Junio C Hamano7d06a8a2008-10-20 05:42:331166--no-verify
1167</dt>
1168<dd>
1169<p>
Junio C Hamanoa28a9202012-06-21 07:08:231170 This option bypasses the pre-rebase hook. See also <a href="githooks.html">githooks(5)</a>.
Junio C Hamano7d06a8a2008-10-20 05:42:331171</p>
1172</dd>
Junio C Hamano68cf15a2010-11-06 01:01:591173<dt class="hdlist1">
Junio C Hamanoeef01fe2010-12-13 08:31:581174--verify
1175</dt>
1176<dd>
1177<p>
1178 Allows the pre-rebase hook to run, which is the default. This option can
Junio C Hamanoa28a9202012-06-21 07:08:231179 be used to override --no-verify. See also <a href="githooks.html">githooks(5)</a>.
Junio C Hamanoeef01fe2010-12-13 08:31:581180</p>
1181</dd>
1182<dt class="hdlist1">
Junio C Hamanod3339982007-02-09 08:38:481183-C&lt;n&gt;
1184</dt>
1185<dd>
1186<p>
1187 Ensure at least &lt;n&gt; lines of surrounding context match before
1188 and after each change. When fewer lines of surrounding
1189 context exist they all must match. By default no context is
1190 ever ignored.
1191</p>
1192</dd>
Junio C Hamano68cf15a2010-11-06 01:01:591193<dt class="hdlist1">
Junio C Hamanoa973f1c2009-03-19 17:47:521194-f
1195</dt>
Junio C Hamano68cf15a2010-11-06 01:01:591196<dt class="hdlist1">
Junio C Hamanoa973f1c2009-03-19 17:47:521197--force-rebase
1198</dt>
1199<dd>
1200<p>
Junio C Hamano53fe0312014-09-09 21:16:171201 Force a rebase even if the current branch is up-to-date and
Junio C Hamanoac12f0e2014-09-19 22:32:511202 the command without <code>--force</code> would return without doing anything.
Junio C Hamanoa973f1c2009-03-19 17:47:521203</p>
Junio C Hamano68cf15a2010-11-06 01:01:591204<div class="paragraph"><p>You may find this (or --no-ff with an interactive rebase) helpful after
Junio C Hamanoef8fbf92010-04-04 19:12:021205reverting a topic branch merge, as this option recreates the topic branch with
1206fresh commits so it can be remerged successfully without needing to "revert
1207the reversion" (see the
Junio C Hamanoe6f28d02013-09-17 21:34:001208<a href="howto/revert-a-faulty-merge.html">revert-a-faulty-merge How-To</a> for details).</p></div>
Junio C Hamanoa973f1c2009-03-19 17:47:521209</dd>
Junio C Hamano68cf15a2010-11-06 01:01:591210<dt class="hdlist1">
Junio C Hamanob1acf022013-12-28 00:33:161211--fork-point
1212</dt>
1213<dt class="hdlist1">
1214--no-fork-point
1215</dt>
1216<dd>
1217<p>
Junio C Hamano9236fea2014-10-14 22:28:091218 Use reflog to find a better common ancestor between &lt;upstream&gt;
1219 and &lt;branch&gt; when calculating which commits have been
1220 introduced by &lt;branch&gt;.
Junio C Hamanob1acf022013-12-28 00:33:161221</p>
Junio C Hamano9236fea2014-10-14 22:28:091222<div class="paragraph"><p>When --fork-point is active, <em>fork_point</em> will be used instead of
1223&lt;upstream&gt; to calculate the set of commits to rebase, where
1224<em>fork_point</em> is the result of <code>git merge-base --fork-point &lt;upstream&gt;
1225&lt;branch&gt;</code> command (see <a href="git-merge-base.html">git-merge-base(1)</a>). If <em>fork_point</em>
1226ends up being empty, the &lt;upstream&gt; will be used as a fallback.</p></div>
1227<div class="paragraph"><p>If either &lt;upstream&gt; or --root is given on the command line, then the
1228default is <code>--no-fork-point</code>, otherwise the default is <code>--fork-point</code>.</p></div>
Junio C Hamanob1acf022013-12-28 00:33:161229</dd>
1230<dt class="hdlist1">
Junio C Hamanofe24db02009-08-22 05:10:471231--ignore-whitespace
1232</dt>
Junio C Hamano68cf15a2010-11-06 01:01:591233<dt class="hdlist1">
Junio C Hamanof8a79222009-03-01 08:02:501234--whitespace=&lt;option&gt;
Junio C Hamano250f03e2007-09-10 01:33:281235</dt>
1236<dd>
1237<p>
Junio C Hamano1aa40d22010-01-21 17:46:431238 These flag are passed to the <em>git apply</em> program
Junio C Hamanoa28a9202012-06-21 07:08:231239 (see <a href="git-apply.html">git-apply(1)</a>) that applies the patch.
Junio C Hamanoec3b9a72009-02-13 08:45:521240 Incompatible with the --interactive option.
Junio C Hamano250f03e2007-09-10 01:33:281241</p>
1242</dd>
Junio C Hamano68cf15a2010-11-06 01:01:591243<dt class="hdlist1">
Junio C Hamanoa973f1c2009-03-19 17:47:521244--committer-date-is-author-date
1245</dt>
Junio C Hamano68cf15a2010-11-06 01:01:591246<dt class="hdlist1">
Junio C Hamanoa973f1c2009-03-19 17:47:521247--ignore-date
1248</dt>
1249<dd>
1250<p>
Junio C Hamano1aa40d22010-01-21 17:46:431251 These flags are passed to <em>git am</em> to easily change the dates
Junio C Hamanoa28a9202012-06-21 07:08:231252 of the rebased commits (see <a href="git-am.html">git-am(1)</a>).
Junio C Hamanoe97d5772010-05-19 08:13:581253 Incompatible with the --interactive option.
Junio C Hamanoa973f1c2009-03-19 17:47:521254</p>
1255</dd>
Junio C Hamano68cf15a2010-11-06 01:01:591256<dt class="hdlist1">
Junio C Hamanoeb415992008-06-08 22:49:471257-i
1258</dt>
Junio C Hamano68cf15a2010-11-06 01:01:591259<dt class="hdlist1">
Junio C Hamanoeb415992008-06-08 22:49:471260--interactive
Junio C Hamano1d90cb02007-07-03 07:05:311261</dt>
1262<dd>
1263<p>
1264 Make a list of the commits which are about to be rebased. Let the
Junio C Hamanodbb64592007-09-01 11:17:391265 user edit that list before rebasing. This mode can also be used to
1266 split commits (see SPLITTING COMMITS below).
Junio C Hamano1d90cb02007-07-03 07:05:311267</p>
Junio C Hamanod7ed4042015-08-03 19:43:001268<div class="paragraph"><p>The commit list format can be changed by setting the configuration option
1269rebase.instructionFormat. A customized instruction format will automatically
1270have the long commit hash prepended to the format.</p></div>
Junio C Hamano1d90cb02007-07-03 07:05:311271</dd>
Junio C Hamano68cf15a2010-11-06 01:01:591272<dt class="hdlist1">
Junio C Hamanoeb415992008-06-08 22:49:471273-p
1274</dt>
Junio C Hamano68cf15a2010-11-06 01:01:591275<dt class="hdlist1">
Junio C Hamanoeb415992008-06-08 22:49:471276--preserve-merges
Junio C Hamano1d90cb02007-07-03 07:05:311277</dt>
1278<dd>
1279<p>
Junio C Hamano8ea9ba92015-04-02 21:08:501280 Recreate merge commits instead of flattening the history by replaying
1281 commits a merge commit introduces. Merge conflict resolutions or manual
1282 amendments to merge commits are not preserved.
Junio C Hamano1d90cb02007-07-03 07:05:311283</p>
Junio C Hamanoac12f0e2014-09-19 22:32:511284<div class="paragraph"><p>This uses the <code>--interactive</code> machinery internally, but combining it
1285with the <code>--interactive</code> option explicitly is generally not a good
Junio C Hamanobb88cf42010-06-21 15:23:551286idea unless you know what you are doing (see BUGS below).</p></div>
Junio C Hamano1d90cb02007-07-03 07:05:311287</dd>
Junio C Hamano68cf15a2010-11-06 01:01:591288<dt class="hdlist1">
Junio C Hamano644936c2012-06-28 23:05:141289-x &lt;cmd&gt;
1290</dt>
1291<dt class="hdlist1">
1292--exec &lt;cmd&gt;
1293</dt>
1294<dd>
1295<p>
1296 Append "exec &lt;cmd&gt;" after each line creating a commit in the
1297 final history. &lt;cmd&gt; will be interpreted as one or more shell
1298 commands.
1299</p>
Junio C Hamanoac12f0e2014-09-19 22:32:511300<div class="paragraph"><p>This option can only be used with the <code>--interactive</code> option
Junio C Hamano644936c2012-06-28 23:05:141301(see INTERACTIVE MODE below).</p></div>
Junio C Hamanoac12f0e2014-09-19 22:32:511302<div class="paragraph"><p>You may execute several commands by either using one instance of <code>--exec</code>
Junio C Hamano644936c2012-06-28 23:05:141303with several commands:</p></div>
1304<div class="literalblock">
1305<div class="content">
Junio C Hamanoac12f0e2014-09-19 22:32:511306<pre><code>git rebase -i --exec "cmd1 &amp;&amp; cmd2 &amp;&amp; ..."</code></pre>
Junio C Hamano644936c2012-06-28 23:05:141307</div></div>
Junio C Hamanoac12f0e2014-09-19 22:32:511308<div class="paragraph"><p>or by giving more than one <code>--exec</code>:</p></div>
Junio C Hamano644936c2012-06-28 23:05:141309<div class="literalblock">
1310<div class="content">
Junio C Hamanoac12f0e2014-09-19 22:32:511311<pre><code>git rebase -i --exec "cmd1" --exec "cmd2" --exec ...</code></pre>
Junio C Hamano644936c2012-06-28 23:05:141312</div></div>
Junio C Hamanoac12f0e2014-09-19 22:32:511313<div class="paragraph"><p>If <code>--autosquash</code> is used, "exec" lines will not be appended for
Junio C Hamano644936c2012-06-28 23:05:141314the intermediate commits, and will only appear at the end of each
1315squash/fixup series.</p></div>
1316</dd>
1317<dt class="hdlist1">
Junio C Hamanobd53dbf2009-01-18 18:26:371318--root
1319</dt>
1320<dd>
1321<p>
1322 Rebase all commits reachable from &lt;branch&gt;, instead of
1323 limiting them with an &lt;upstream&gt;. This allows you to rebase
Junio C Hamano02482692012-07-16 05:28:391324 the root commit(s) on a branch. When used with --onto, it
Junio C Hamanobd53dbf2009-01-18 18:26:371325 will skip changes already contained in &lt;newbase&gt; (instead of
Junio C Hamano02482692012-07-16 05:28:391326 &lt;upstream&gt;) whereas without --onto it will operate on every change.
1327 When used together with both --onto and --preserve-merges,
1328 <em>all</em> root commits will be rewritten to have &lt;newbase&gt; as parent
Junio C Hamanobd53dbf2009-01-18 18:26:371329 instead.
1330</p>
1331</dd>
Junio C Hamano68cf15a2010-11-06 01:01:591332<dt class="hdlist1">
Junio C Hamanoa9701f02010-01-21 00:42:161333--autosquash
1334</dt>
Junio C Hamano68cf15a2010-11-06 01:01:591335<dt class="hdlist1">
Junio C Hamano075ae872010-09-01 18:43:071336--no-autosquash
1337</dt>
Junio C Hamanoa9701f02010-01-21 00:42:161338<dd>
1339<p>
1340 When the commit log message begins with "squash! &#8230;" (or
1341 "fixup! &#8230;"), and there is a commit whose title begins with
1342 the same &#8230;, automatically modify the todo list of rebase -i
Junio C Hamano364b6a42010-01-22 07:57:591343 so that the commit marked for squashing comes right after the
Junio C Hamanoa9701f02010-01-21 00:42:161344 commit to be modified, and change the action of the moved
Junio C Hamanoac12f0e2014-09-19 22:32:511345 commit from <code>pick</code> to <code>squash</code> (or <code>fixup</code>). Ignores subsequent
Junio C Hamanoa1952302013-07-01 21:31:181346 "fixup! " or "squash! " after the first, in case you referred to an
Junio C Hamanoac12f0e2014-09-19 22:32:511347 earlier fixup/squash with <code>git commit --fixup/--squash</code>.
Junio C Hamanoa9701f02010-01-21 00:42:161348</p>
Junio C Hamano68cf15a2010-11-06 01:01:591349<div class="paragraph"><p>This option is only valid when the <em>--interactive</em> option is used.</p></div>
1350<div class="paragraph"><p>If the <em>--autosquash</em> option is enabled by default using the
Junio C Hamano322c6242015-03-23 21:32:461351configuration variable <code>rebase.autoSquash</code>, this option can be
Junio C Hamano075ae872010-09-01 18:43:071352used to override and disable this setting.</p></div>
Junio C Hamanoef8fbf92010-04-04 19:12:021353</dd>
Junio C Hamano68cf15a2010-11-06 01:01:591354<dt class="hdlist1">
Junio C Hamano1eb56092015-10-05 20:39:531355--autostash
1356</dt>
1357<dt class="hdlist1">
1358--no-autostash
Junio C Hamanof1f5a7b2013-06-11 22:23:521359</dt>
1360<dd>
1361<p>
1362 Automatically create a temporary stash before the operation
1363 begins, and apply it after the operation ends. This means
1364 that you can run rebase on a dirty worktree. However, use
1365 with care: the final stash application after a successful
1366 rebase might result in non-trivial conflicts.
1367</p>
1368</dd>
1369<dt class="hdlist1">
Junio C Hamanoef8fbf92010-04-04 19:12:021370--no-ff
1371</dt>
1372<dd>
1373<p>
1374 With --interactive, cherry-pick all rebased commits instead of
1375 fast-forwarding over the unchanged ones. This ensures that the
1376 entire history of the rebased branch is composed of new commits.
1377</p>
Junio C Hamano68cf15a2010-11-06 01:01:591378<div class="paragraph"><p>Without --interactive, this is a synonym for --force-rebase.</p></div>
1379<div class="paragraph"><p>You may find this helpful after reverting a topic branch merge, as this option
Junio C Hamanoef8fbf92010-04-04 19:12:021380recreates the topic branch with fresh commits so it can be remerged
1381successfully without needing to "revert the reversion" (see the
Junio C Hamanoe6f28d02013-09-17 21:34:001382<a href="howto/revert-a-faulty-merge.html">revert-a-faulty-merge How-To</a> for details).</p></div>
Junio C Hamanoa9701f02010-01-21 00:42:161383</dd>
Junio C Hamanoba4b9282008-07-06 05:20:311384</dl></div>
Junio C Hamano97f518c2006-06-22 19:49:351385</div>
Junio C Hamano9d971152012-12-19 00:43:111386</div>
1387<div class="sect1">
Junio C Hamanoba4b9282008-07-06 05:20:311388<h2 id="_merge_strategies">MERGE STRATEGIES</h2>
Junio C Hamano97f518c2006-06-22 19:49:351389<div class="sectionbody">
Junio C Hamanoac12f0e2014-09-19 22:32:511390<div class="paragraph"><p>The merge mechanism (<code>git merge</code> and <code>git pull</code> commands) allows the
1391backend <em>merge strategies</em> to be chosen with <code>-s</code> option. Some strategies
1392can also take their own options, which can be passed by giving <code>-X&lt;option&gt;</code>
1393arguments to <code>git merge</code> and/or <code>git pull</code>.</p></div>
Junio C Hamano68cf15a2010-11-06 01:01:591394<div class="dlist"><dl>
1395<dt class="hdlist1">
Junio C Hamano97f518c2006-06-22 19:49:351396resolve
1397</dt>
1398<dd>
1399<p>
1400 This can only resolve two heads (i.e. the current branch
Junio C Hamano1de75722009-03-26 08:39:381401 and another branch you pulled from) using a 3-way merge
Junio C Hamano97f518c2006-06-22 19:49:351402 algorithm. It tries to carefully detect criss-cross
1403 merge ambiguities and is considered generally safe and
1404 fast.
1405</p>
1406</dd>
Junio C Hamano68cf15a2010-11-06 01:01:591407<dt class="hdlist1">
Junio C Hamano97f518c2006-06-22 19:49:351408recursive
1409</dt>
1410<dd>
1411<p>
Junio C Hamano1de75722009-03-26 08:39:381412 This can only resolve two heads using a 3-way merge
1413 algorithm. When there is more than one common
1414 ancestor that can be used for 3-way merge, it creates a
Junio C Hamano97f518c2006-06-22 19:49:351415 merged tree of the common ancestors and uses that as
1416 the reference tree for the 3-way merge. This has been
1417 reported to result in fewer merge conflicts without
Junio C Hamano5b3533d2014-02-27 23:07:151418 causing mismerges by tests done on actual merge commits
Junio C Hamano97f518c2006-06-22 19:49:351419 taken from Linux 2.6 kernel development history.
1420 Additionally this can detect and handle merges involving
1421 renames. This is the default merge strategy when
1422 pulling or merging one branch.
1423</p>
Junio C Hamano68cf15a2010-11-06 01:01:591424<div class="paragraph"><p>The <em>recursive</em> strategy can take the following options:</p></div>
1425<div class="dlist"><dl>
1426<dt class="hdlist1">
Junio C Hamano1aa40d22010-01-21 17:46:431427ours
1428</dt>
1429<dd>
1430<p>
1431 This option forces conflicting hunks to be auto-resolved cleanly by
1432 favoring <em>our</em> version. Changes from the other tree that do not
1433 conflict with our side are reflected to the merge result.
Junio C Hamanoa3cfb762012-09-15 05:32:141434 For a binary file, the entire contents are taken from our side.
Junio C Hamano1aa40d22010-01-21 17:46:431435</p>
Junio C Hamano68cf15a2010-11-06 01:01:591436<div class="paragraph"><p>This should not be confused with the <em>ours</em> merge strategy, which does not
Junio C Hamano1aa40d22010-01-21 17:46:431437even look at what the other tree contains at all. It discards everything
1438the other tree did, declaring <em>our</em> history contains all that happened in it.</p></div>
1439</dd>
Junio C Hamano68cf15a2010-11-06 01:01:591440<dt class="hdlist1">
Junio C Hamano1aa40d22010-01-21 17:46:431441theirs
1442</dt>
1443<dd>
1444<p>
Junio C Hamanoa3cfb762012-09-15 05:32:141445 This is the opposite of <em>ours</em>.
Junio C Hamano1aa40d22010-01-21 17:46:431446</p>
1447</dd>
Junio C Hamano68cf15a2010-11-06 01:01:591448<dt class="hdlist1">
Junio C Hamano39c7a692010-10-27 06:08:541449patience
1450</dt>
1451<dd>
1452<p>
1453 With this option, <em>merge-recursive</em> spends a little extra time
1454 to avoid mismerges that sometimes occur due to unimportant
1455 matching lines (e.g., braces from distinct functions). Use
1456 this when the branches to be merged have diverged wildly.
Junio C Hamanoac12f0e2014-09-19 22:32:511457 See also <a href="git-diff.html">git-diff(1)</a> <code>--patience</code>.
Junio C Hamano39c7a692010-10-27 06:08:541458</p>
1459</dd>
Junio C Hamano68cf15a2010-11-06 01:01:591460<dt class="hdlist1">
Junio C Hamano1575c202013-04-15 20:25:591461diff-algorithm=[patience|minimal|histogram|myers]
1462</dt>
1463<dd>
1464<p>
1465 Tells <em>merge-recursive</em> to use a different diff algorithm, which
1466 can help avoid mismerges that occur due to unimportant matching
1467 lines (such as braces from distinct functions). See also
Junio C Hamanoac12f0e2014-09-19 22:32:511468 <a href="git-diff.html">git-diff(1)</a> <code>--diff-algorithm</code>.
Junio C Hamano1575c202013-04-15 20:25:591469</p>
1470</dd>
1471<dt class="hdlist1">
Junio C Hamano39c7a692010-10-27 06:08:541472ignore-space-change
1473</dt>
Junio C Hamano68cf15a2010-11-06 01:01:591474<dt class="hdlist1">
Junio C Hamano39c7a692010-10-27 06:08:541475ignore-all-space
1476</dt>
Junio C Hamano68cf15a2010-11-06 01:01:591477<dt class="hdlist1">
Junio C Hamano39c7a692010-10-27 06:08:541478ignore-space-at-eol
1479</dt>
1480<dd>
1481<p>
1482 Treats lines with the indicated type of whitespace change as
1483 unchanged for the sake of a three-way merge. Whitespace
1484 changes mixed with other changes to a line are not ignored.
Junio C Hamanoac12f0e2014-09-19 22:32:511485 See also <a href="git-diff.html">git-diff(1)</a> <code>-b</code>, <code>-w</code>, and
1486 <code>--ignore-space-at-eol</code>.
Junio C Hamano39c7a692010-10-27 06:08:541487</p>
Junio C Hamano68cf15a2010-11-06 01:01:591488<div class="ulist"><ul>
Junio C Hamano39c7a692010-10-27 06:08:541489<li>
1490<p>
1491If <em>their</em> version only introduces whitespace changes to a line,
1492 <em>our</em> version is used;
1493</p>
1494</li>
1495<li>
1496<p>
1497If <em>our</em> version introduces whitespace changes but <em>their</em>
1498 version includes a substantial change, <em>their</em> version is used;
1499</p>
1500</li>
1501<li>
1502<p>
1503Otherwise, the merge proceeds in the usual way.
1504</p>
1505</li>
1506</ul></div>
1507</dd>
Junio C Hamano68cf15a2010-11-06 01:01:591508<dt class="hdlist1">
Junio C Hamano2db3e752010-09-03 21:33:061509renormalize
1510</dt>
1511<dd>
1512<p>
1513 This runs a virtual check-out and check-in of all three stages
1514 of a file when resolving a three-way merge. This option is
1515 meant to be used when merging branches with different clean
1516 filters or end-of-line normalization rules. See "Merging
1517 branches with differing checkin/checkout attributes" in
Junio C Hamanoa28a9202012-06-21 07:08:231518 <a href="gitattributes.html">gitattributes(5)</a> for details.
Junio C Hamano2db3e752010-09-03 21:33:061519</p>
1520</dd>
Junio C Hamano68cf15a2010-11-06 01:01:591521<dt class="hdlist1">
Junio C Hamano2db3e752010-09-03 21:33:061522no-renormalize
1523</dt>
1524<dd>
1525<p>
Junio C Hamanoac12f0e2014-09-19 22:32:511526 Disables the <code>renormalize</code> option. This overrides the
1527 <code>merge.renormalize</code> configuration variable.
Junio C Hamano2db3e752010-09-03 21:33:061528</p>
1529</dd>
Junio C Hamano68cf15a2010-11-06 01:01:591530<dt class="hdlist1">
Junio C Hamano39c7a692010-10-27 06:08:541531rename-threshold=&lt;n&gt;
1532</dt>
1533<dd>
1534<p>
1535 Controls the similarity threshold used for rename detection.
Junio C Hamanoac12f0e2014-09-19 22:32:511536 See also <a href="git-diff.html">git-diff(1)</a> <code>-M</code>.
Junio C Hamano39c7a692010-10-27 06:08:541537</p>
1538</dd>
Junio C Hamano68cf15a2010-11-06 01:01:591539<dt class="hdlist1">
Junio C Hamanod2179ef2010-10-22 04:12:171540subtree[=&lt;path&gt;]
Junio C Hamano1aa40d22010-01-21 17:46:431541</dt>
1542<dd>
1543<p>
1544 This option is a more advanced form of <em>subtree</em> strategy, where
1545 the strategy makes a guess on how two trees must be shifted to
1546 match with each other when merging. Instead, the specified path
1547 is prefixed (or stripped from the beginning) to make the shape of
1548 two trees to match.
1549</p>
1550</dd>
1551</dl></div>
Junio C Hamano97f518c2006-06-22 19:49:351552</dd>
Junio C Hamano68cf15a2010-11-06 01:01:591553<dt class="hdlist1">
Junio C Hamano97f518c2006-06-22 19:49:351554octopus
1555</dt>
1556<dd>
1557<p>
Junio C Hamano1de75722009-03-26 08:39:381558 This resolves cases with more than two heads, but refuses to do
1559 a complex merge that needs manual resolution. It is
Junio C Hamano97f518c2006-06-22 19:49:351560 primarily meant to be used for bundling topic branch
1561 heads together. This is the default merge strategy when
Junio C Hamano1de75722009-03-26 08:39:381562 pulling or merging more than one branch.
Junio C Hamano97f518c2006-06-22 19:49:351563</p>
1564</dd>
Junio C Hamano68cf15a2010-11-06 01:01:591565<dt class="hdlist1">
Junio C Hamano97f518c2006-06-22 19:49:351566ours
1567</dt>
1568<dd>
1569<p>
Junio C Hamanobf984de2009-11-23 06:11:191570 This resolves any number of heads, but the resulting tree of the
1571 merge is always that of the current branch head, effectively
1572 ignoring all changes from all other branches. It is meant to
Junio C Hamano97f518c2006-06-22 19:49:351573 be used to supersede old development history of side
Junio C Hamano1aa40d22010-01-21 17:46:431574 branches. Note that this is different from the -Xours option to
1575 the <em>recursive</em> merge strategy.
Junio C Hamano97f518c2006-06-22 19:49:351576</p>
1577</dd>
Junio C Hamano68cf15a2010-11-06 01:01:591578<dt class="hdlist1">
Junio C Hamanoe6c92032008-03-19 09:24:341579subtree
1580</dt>
1581<dd>
1582<p>
1583 This is a modified recursive strategy. When merging trees A and
1584 B, if B corresponds to a subtree of A, B is first adjusted to
1585 match the tree structure of A, instead of reading the trees at
1586 the same level. This adjustment is also done to the common
1587 ancestor tree.
1588</p>
1589</dd>
Junio C Hamanoba4b9282008-07-06 05:20:311590</dl></div>
Junio C Hamanocf77b042013-12-17 23:54:211591<div class="paragraph"><p>With the strategies that use 3-way merge (including the default, <em>recursive</em>),
1592if a change is made on both branches, but later reverted on one of the
1593branches, that change will be present in the merged result; some people find
1594this behavior confusing. It occurs because only the heads and the merge base
1595are considered when performing a merge, not the individual commits. The merge
1596algorithm therefore considers the reverted change as no change at all, and
1597substitutes the changed version instead.</p></div>
Junio C Hamano1a4e8412005-12-27 08:17:231598</div>
Junio C Hamano9d971152012-12-19 00:43:111599</div>
1600<div class="sect1">
Junio C Hamanoba4b9282008-07-06 05:20:311601<h2 id="_notes">NOTES</h2>
Junio C Hamano6112cad2006-05-02 07:28:061602<div class="sectionbody">
Junio C Hamano68cf15a2010-11-06 01:01:591603<div class="paragraph"><p>You should understand the implications of using <em>git rebase</em> on a
Junio C Hamano7d06a8a2008-10-20 05:42:331604repository that you share. See also RECOVERING FROM UPSTREAM REBASE
1605below.</p></div>
Junio C Hamano68cf15a2010-11-06 01:01:591606<div class="paragraph"><p>When the git-rebase command is run, it will first execute a "pre-rebase"
Junio C Hamano6112cad2006-05-02 07:28:061607hook if one exists. You can use this hook to do sanity checks and
Junio C Hamano68cf15a2010-11-06 01:01:591608reject the rebase if it isn&#8217;t appropriate. Please see the template
Junio C Hamanoba4b9282008-07-06 05:20:311609pre-rebase hook script for an example.</p></div>
Junio C Hamano68cf15a2010-11-06 01:01:591610<div class="paragraph"><p>Upon completion, &lt;branch&gt; will be the current branch.</p></div>
Junio C Hamano6112cad2006-05-02 07:28:061611</div>
Junio C Hamano9d971152012-12-19 00:43:111612</div>
1613<div class="sect1">
Junio C Hamanoba4b9282008-07-06 05:20:311614<h2 id="_interactive_mode">INTERACTIVE MODE</h2>
Junio C Hamano1a4e8412005-12-27 08:17:231615<div class="sectionbody">
Junio C Hamano68cf15a2010-11-06 01:01:591616<div class="paragraph"><p>Rebasing interactively means that you have a chance to edit the commits
Junio C Hamano1d90cb02007-07-03 07:05:311617which are rebased. You can reorder the commits, and you can
Junio C Hamanoba4b9282008-07-06 05:20:311618remove them (weeding out bad or otherwise unwanted patches).</p></div>
Junio C Hamano68cf15a2010-11-06 01:01:591619<div class="paragraph"><p>The interactive mode is meant for this type of workflow:</p></div>
1620<div class="olist arabic"><ol class="arabic">
Junio C Hamano1d90cb02007-07-03 07:05:311621<li>
1622<p>
1623have a wonderful idea
1624</p>
1625</li>
1626<li>
1627<p>
1628hack on the code
1629</p>
1630</li>
1631<li>
1632<p>
1633prepare a series for submission
1634</p>
1635</li>
1636<li>
1637<p>
1638submit
1639</p>
1640</li>
Junio C Hamanoba4b9282008-07-06 05:20:311641</ol></div>
Junio C Hamano68cf15a2010-11-06 01:01:591642<div class="paragraph"><p>where point 2. consists of several instances of</p></div>
Junio C Hamano0ff98162012-03-31 18:19:091643<div class="paragraph"><p>a) regular use</p></div>
Junio C Hamano68cf15a2010-11-06 01:01:591644<div class="olist arabic"><ol class="arabic">
Junio C Hamano1d90cb02007-07-03 07:05:311645<li>
1646<p>
1647finish something worthy of a commit
1648</p>
1649</li>
1650<li>
1651<p>
1652commit
1653</p>
1654</li>
Junio C Hamanoba4b9282008-07-06 05:20:311655</ol></div>
Junio C Hamano0ff98162012-03-31 18:19:091656<div class="paragraph"><p>b) independent fixup</p></div>
Junio C Hamano68cf15a2010-11-06 01:01:591657<div class="olist arabic"><ol class="arabic">
Junio C Hamano1d90cb02007-07-03 07:05:311658<li>
1659<p>
1660realize that something does not work
1661</p>
1662</li>
1663<li>
1664<p>
1665fix that
1666</p>
1667</li>
1668<li>
1669<p>
1670commit it
1671</p>
1672</li>
Junio C Hamanoba4b9282008-07-06 05:20:311673</ol></div>
Junio C Hamano68cf15a2010-11-06 01:01:591674<div class="paragraph"><p>Sometimes the thing fixed in b.2. cannot be amended to the not-quite
Junio C Hamano1d90cb02007-07-03 07:05:311675perfect commit it fixes, because that commit is buried deeply in a
1676patch series. That is exactly what interactive rebase is for: use it
1677after plenty of "a"s and "b"s, by rearranging and editing
Junio C Hamanoba4b9282008-07-06 05:20:311678commits, and squashing multiple commits into one.</p></div>
Junio C Hamano68cf15a2010-11-06 01:01:591679<div class="paragraph"><p>Start it with the last commit you want to retain as-is:</p></div>
Junio C Hamano1d90cb02007-07-03 07:05:311680<div class="literalblock">
1681<div class="content">
Junio C Hamanoac12f0e2014-09-19 22:32:511682<pre><code>git rebase -i &lt;after-this-commit&gt;</code></pre>
Junio C Hamano1d90cb02007-07-03 07:05:311683</div></div>
Junio C Hamano68cf15a2010-11-06 01:01:591684<div class="paragraph"><p>An editor will be fired up with all the commits in your current branch
Junio C Hamano1d90cb02007-07-03 07:05:311685(ignoring merge commits), which come after the given commit. You can
Junio C Hamano68cf15a2010-11-06 01:01:591686reorder the commits in this list to your heart&#8217;s content, and you can
Junio C Hamanoba4b9282008-07-06 05:20:311687remove them. The list looks more or less like this:</p></div>
Junio C Hamano1d90cb02007-07-03 07:05:311688<div class="listingblock">
1689<div class="content">
Junio C Hamanoac12f0e2014-09-19 22:32:511690<pre><code>pick deadbee The oneline of this commit
Junio C Hamano1d90cb02007-07-03 07:05:311691pick fa1afe1 The oneline of the next commit
Junio C Hamanoac12f0e2014-09-19 22:32:511692...</code></pre>
Junio C Hamano1d90cb02007-07-03 07:05:311693</div></div>
Junio C Hamano68cf15a2010-11-06 01:01:591694<div class="paragraph"><p>The oneline descriptions are purely for your pleasure; <em>git rebase</em> will
Junio C Hamano1d90cb02007-07-03 07:05:311695not look at them but at the commit names ("deadbee" and "fa1afe1" in this
Junio C Hamanoba4b9282008-07-06 05:20:311696example), so do not delete or edit the names.</p></div>
Junio C Hamano68cf15a2010-11-06 01:01:591697<div class="paragraph"><p>By replacing the command "pick" with the command "edit", you can tell
Junio C Hamano1aa40d22010-01-21 17:46:431698<em>git rebase</em> to stop after applying that commit, so that you can edit
Junio C Hamano1d90cb02007-07-03 07:05:311699the files and/or the commit message, amend the commit, and continue
Junio C Hamanoba4b9282008-07-06 05:20:311700rebasing.</p></div>
Junio C Hamano68cf15a2010-11-06 01:01:591701<div class="paragraph"><p>If you just want to edit the commit message for a commit, replace the
Junio C Hamano3d23a0a2009-10-19 08:04:301702command "pick" with the command "reword".</p></div>
Junio C Hamanod7ed4042015-08-03 19:43:001703<div class="paragraph"><p>To drop a commit, replace the command "pick" with "drop", or just
1704delete the matching line.</p></div>
Junio C Hamano68cf15a2010-11-06 01:01:591705<div class="paragraph"><p>If you want to fold two or more commits into one, replace the command
Junio C Hamanoa9701f02010-01-21 00:42:161706"pick" for the second and subsequent commits with "squash" or "fixup".
1707If the commits had different authors, the folded commit will be
1708attributed to the author of the first commit. The suggested commit
1709message for the folded commit is the concatenation of the commit
1710messages of the first commit and of those with the "squash" command,
1711but omits the commit messages of commits with the "fixup" command.</p></div>
Junio C Hamano68cf15a2010-11-06 01:01:591712<div class="paragraph"><p><em>git rebase</em> will stop when "pick" has been replaced with "edit" or
Junio C Hamano3d23a0a2009-10-19 08:04:301713when a command fails due to merge errors. When you are done editing
Junio C Hamanoac12f0e2014-09-19 22:32:511714and/or resolving conflicts you can continue with <code>git rebase --continue</code>.</p></div>
Junio C Hamano68cf15a2010-11-06 01:01:591715<div class="paragraph"><p>For example, if you want to reorder the last 5 commits, such that what
Junio C Hamano1d90cb02007-07-03 07:05:311716was HEAD~4 becomes the new HEAD. To achieve that, you would call
Junio C Hamano1aa40d22010-01-21 17:46:431717<em>git rebase</em> like this:</p></div>
Junio C Hamano1d90cb02007-07-03 07:05:311718<div class="listingblock">
1719<div class="content">
Junio C Hamanoac12f0e2014-09-19 22:32:511720<pre><code>$ git rebase -i HEAD~5</code></pre>
Junio C Hamano1d90cb02007-07-03 07:05:311721</div></div>
Junio C Hamano68cf15a2010-11-06 01:01:591722<div class="paragraph"><p>And move the first patch to the end of the list.</p></div>
1723<div class="paragraph"><p>You might want to preserve merges, if you have a history like this:</p></div>
Junio C Hamano1d90cb02007-07-03 07:05:311724<div class="listingblock">
1725<div class="content">
Junio C Hamanoac12f0e2014-09-19 22:32:511726<pre><code> X
Junio C Hamano1d90cb02007-07-03 07:05:311727 \
1728 A---M---B
1729 /
Junio C Hamanoac12f0e2014-09-19 22:32:511730---o---O---P---Q</code></pre>
Junio C Hamano1d90cb02007-07-03 07:05:311731</div></div>
Junio C Hamano68cf15a2010-11-06 01:01:591732<div class="paragraph"><p>Suppose you want to rebase the side branch starting at "A" to "Q". Make
Junio C Hamanoba4b9282008-07-06 05:20:311733sure that the current HEAD is "B", and call</p></div>
Junio C Hamano1d90cb02007-07-03 07:05:311734<div class="listingblock">
1735<div class="content">
Junio C Hamanoac12f0e2014-09-19 22:32:511736<pre><code>$ git rebase -i -p --onto Q O</code></pre>
Junio C Hamano1d90cb02007-07-03 07:05:311737</div></div>
Junio C Hamano68cf15a2010-11-06 01:01:591738<div class="paragraph"><p>Reordering and editing commits usually creates untested intermediate
Junio C Hamano53ba6d02010-08-22 07:25:121739steps. You may want to check that your history editing did not break
1740anything by running a test, or at least recompiling at intermediate
1741points in history by using the "exec" command (shortcut "x"). You may
1742do so by creating a todo list like this one:</p></div>
1743<div class="listingblock">
1744<div class="content">
Junio C Hamanoac12f0e2014-09-19 22:32:511745<pre><code>pick deadbee Implement feature XXX
Junio C Hamano53ba6d02010-08-22 07:25:121746fixup f1a5c00 Fix to feature XXX
1747exec make
1748pick c0ffeee The oneline of the next commit
1749edit deadbab The oneline of the commit after
1750exec cd subdir; make test
Junio C Hamanoac12f0e2014-09-19 22:32:511751...</code></pre>
Junio C Hamano53ba6d02010-08-22 07:25:121752</div></div>
Junio C Hamano68cf15a2010-11-06 01:01:591753<div class="paragraph"><p>The interactive rebase will stop when a command fails (i.e. exits with
Junio C Hamano53ba6d02010-08-22 07:25:121754non-0 status) to give you an opportunity to fix the problem. You can
Junio C Hamanoac12f0e2014-09-19 22:32:511755continue with <code>git rebase --continue</code>.</p></div>
Junio C Hamano68cf15a2010-11-06 01:01:591756<div class="paragraph"><p>The "exec" command launches the command in a shell (the one specified
Junio C Hamanoac12f0e2014-09-19 22:32:511757in <code>$SHELL</code>, or the default shell if <code>$SHELL</code> is not set), so you can
Junio C Hamano53ba6d02010-08-22 07:25:121758use shell features (like "cd", "&gt;", ";" &#8230;). The command is run from
1759the root of the working tree.</p></div>
Junio C Hamano644936c2012-06-28 23:05:141760<div class="listingblock">
1761<div class="content">
Junio C Hamanoac12f0e2014-09-19 22:32:511762<pre><code>$ git rebase -i --exec "make test"</code></pre>
Junio C Hamano644936c2012-06-28 23:05:141763</div></div>
1764<div class="paragraph"><p>This command lets you check that intermediate commits are compilable.
1765The todo list becomes like that:</p></div>
1766<div class="listingblock">
1767<div class="content">
Junio C Hamanoac12f0e2014-09-19 22:32:511768<pre><code>pick 5928aea one
Junio C Hamano644936c2012-06-28 23:05:141769exec make test
1770pick 04d0fda two
1771exec make test
1772pick ba46169 three
1773exec make test
1774pick f4593f9 four
Junio C Hamanoac12f0e2014-09-19 22:32:511775exec make test</code></pre>
Junio C Hamano644936c2012-06-28 23:05:141776</div></div>
Junio C Hamano1d90cb02007-07-03 07:05:311777</div>
Junio C Hamano9d971152012-12-19 00:43:111778</div>
1779<div class="sect1">
Junio C Hamanoba4b9282008-07-06 05:20:311780<h2 id="_splitting_commits">SPLITTING COMMITS</h2>
Junio C Hamanodbb64592007-09-01 11:17:391781<div class="sectionbody">
Junio C Hamano68cf15a2010-11-06 01:01:591782<div class="paragraph"><p>In interactive mode, you can mark commits with the action "edit". However,
Junio C Hamano1aa40d22010-01-21 17:46:431783this does not necessarily mean that <em>git rebase</em> expects the result of this
Junio C Hamanodbb64592007-09-01 11:17:391784edit to be exactly one commit. Indeed, you can undo the commit, or you can
Junio C Hamanoba4b9282008-07-06 05:20:311785add other commits. This can be used to split a commit into two:</p></div>
Junio C Hamano68cf15a2010-11-06 01:01:591786<div class="ulist"><ul>
Junio C Hamanodbb64592007-09-01 11:17:391787<li>
1788<p>
Junio C Hamanoac12f0e2014-09-19 22:32:511789Start an interactive rebase with <code>git rebase -i &lt;commit&gt;^</code>, where
Junio C Hamanodbb64592007-09-01 11:17:391790 &lt;commit&gt; is the commit you want to split. In fact, any commit range
1791 will do, as long as it contains that commit.
1792</p>
1793</li>
1794<li>
1795<p>
1796Mark the commit you want to split with the action "edit".
1797</p>
1798</li>
1799<li>
1800<p>
Junio C Hamanoac12f0e2014-09-19 22:32:511801When it comes to editing that commit, execute <code>git reset HEAD^</code>. The
Junio C Hamanodbb64592007-09-01 11:17:391802 effect is that the HEAD is rewound by one, and the index follows suit.
1803 However, the working tree stays the same.
1804</p>
1805</li>
1806<li>
1807<p>
1808Now add the changes to the index that you want to have in the first
Junio C Hamanoac12f0e2014-09-19 22:32:511809 commit. You can use <code>git add</code> (possibly interactively) or
Junio C Hamano1aa40d22010-01-21 17:46:431810 <em>git gui</em> (or both) to do that.
Junio C Hamanodbb64592007-09-01 11:17:391811</p>
1812</li>
1813<li>
1814<p>
1815Commit the now-current index with whatever commit message is appropriate
1816 now.
1817</p>
1818</li>
1819<li>
1820<p>
1821Repeat the last two steps until your working tree is clean.
1822</p>
1823</li>
1824<li>
1825<p>
Junio C Hamanoac12f0e2014-09-19 22:32:511826Continue the rebase with <code>git rebase --continue</code>.
Junio C Hamanodbb64592007-09-01 11:17:391827</p>
1828</li>
Junio C Hamanoba4b9282008-07-06 05:20:311829</ul></div>
Junio C Hamano68cf15a2010-11-06 01:01:591830<div class="paragraph"><p>If you are not absolutely sure that the intermediate revisions are
Junio C Hamanodbb64592007-09-01 11:17:391831consistent (they compile, pass the testsuite, etc.) you should use
Junio C Hamano1aa40d22010-01-21 17:46:431832<em>git stash</em> to stash away the not-yet-committed changes
Junio C Hamanoba4b9282008-07-06 05:20:311833after each commit, test, and amend the commit if fixes are necessary.</p></div>
Junio C Hamanodbb64592007-09-01 11:17:391834</div>
Junio C Hamano9d971152012-12-19 00:43:111835</div>
1836<div class="sect1">
Junio C Hamano7d06a8a2008-10-20 05:42:331837<h2 id="_recovering_from_upstream_rebase">RECOVERING FROM UPSTREAM REBASE</h2>
1838<div class="sectionbody">
Junio C Hamano68cf15a2010-11-06 01:01:591839<div class="paragraph"><p>Rebasing (or any other form of rewriting) a branch that others have
Junio C Hamano7d06a8a2008-10-20 05:42:331840based work on is a bad idea: anyone downstream of it is forced to
1841manually fix their history. This section explains how to do the fix
Junio C Hamano68cf15a2010-11-06 01:01:591842from the downstream&#8217;s point of view. The real fix, however, would be
Junio C Hamano7d06a8a2008-10-20 05:42:331843to avoid rebasing the upstream in the first place.</p></div>
Junio C Hamano68cf15a2010-11-06 01:01:591844<div class="paragraph"><p>To illustrate, suppose you are in a situation where someone develops a
Junio C Hamano7d06a8a2008-10-20 05:42:331845<em>subsystem</em> branch, and you are working on a <em>topic</em> that is dependent
1846on this <em>subsystem</em>. You might end up with a history like the
1847following:</p></div>
1848<div class="listingblock">
1849<div class="content">
Junio C Hamanoac12f0e2014-09-19 22:32:511850<pre><code> o---o---o---o---o---o---o---o---o master
Junio C Hamano7d06a8a2008-10-20 05:42:331851 \
1852 o---o---o---o---o subsystem
1853 \
Junio C Hamanoac12f0e2014-09-19 22:32:511854 *---*---* topic</code></pre>
Junio C Hamano7d06a8a2008-10-20 05:42:331855</div></div>
Junio C Hamano68cf15a2010-11-06 01:01:591856<div class="paragraph"><p>If <em>subsystem</em> is rebased against <em>master</em>, the following happens:</p></div>
Junio C Hamano7d06a8a2008-10-20 05:42:331857<div class="listingblock">
1858<div class="content">
Junio C Hamanoac12f0e2014-09-19 22:32:511859<pre><code> o---o---o---o---o---o---o---o master
Junio C Hamano7d06a8a2008-10-20 05:42:331860 \ \
1861 o---o---o---o---o o'--o'--o'--o'--o' subsystem
1862 \
Junio C Hamanoac12f0e2014-09-19 22:32:511863 *---*---* topic</code></pre>
Junio C Hamano7d06a8a2008-10-20 05:42:331864</div></div>
Junio C Hamano68cf15a2010-11-06 01:01:591865<div class="paragraph"><p>If you now continue development as usual, and eventually merge <em>topic</em>
Junio C Hamano7d06a8a2008-10-20 05:42:331866to <em>subsystem</em>, the commits from <em>subsystem</em> will remain duplicated forever:</p></div>
1867<div class="listingblock">
1868<div class="content">
Junio C Hamanoac12f0e2014-09-19 22:32:511869<pre><code> o---o---o---o---o---o---o---o master
Junio C Hamano7d06a8a2008-10-20 05:42:331870 \ \
1871 o---o---o---o---o o'--o'--o'--o'--o'--M subsystem
1872 \ /
Junio C Hamanoac12f0e2014-09-19 22:32:511873 *---*---*-..........-*--* topic</code></pre>
Junio C Hamano7d06a8a2008-10-20 05:42:331874</div></div>
Junio C Hamano68cf15a2010-11-06 01:01:591875<div class="paragraph"><p>Such duplicates are generally frowned upon because they clutter up
Junio C Hamano7d06a8a2008-10-20 05:42:331876history, making it harder to follow. To clean things up, you need to
1877transplant the commits on <em>topic</em> to the new <em>subsystem</em> tip, i.e.,
1878rebase <em>topic</em>. This becomes a ripple effect: anyone downstream from
1879<em>topic</em> is forced to rebase too, and so on!</p></div>
Junio C Hamano68cf15a2010-11-06 01:01:591880<div class="paragraph"><p>There are two kinds of fixes, discussed in the following subsections:</p></div>
1881<div class="dlist"><dl>
1882<dt class="hdlist1">
Junio C Hamano7d06a8a2008-10-20 05:42:331883Easy case: The changes are literally the same.
1884</dt>
1885<dd>
1886<p>
1887 This happens if the <em>subsystem</em> rebase was a simple rebase and
1888 had no conflicts.
1889</p>
1890</dd>
Junio C Hamano68cf15a2010-11-06 01:01:591891<dt class="hdlist1">
Junio C Hamano7d06a8a2008-10-20 05:42:331892Hard case: The changes are not the same.
1893</dt>
1894<dd>
1895<p>
1896 This happens if the <em>subsystem</em> rebase had conflicts, or used
Junio C Hamanoac12f0e2014-09-19 22:32:511897 <code>--interactive</code> to omit, edit, squash, or fixup commits; or
1898 if the upstream used one of <code>commit --amend</code>, <code>reset</code>, or
1899 <code>filter-branch</code>.
Junio C Hamano7d06a8a2008-10-20 05:42:331900</p>
1901</dd>
1902</dl></div>
Junio C Hamano9d971152012-12-19 00:43:111903<div class="sect2">
1904<h3 id="_the_easy_case">The easy case</h3>
Junio C Hamano68cf15a2010-11-06 01:01:591905<div class="paragraph"><p>Only works if the changes (patch IDs based on the diff contents) on
Junio C Hamano7d06a8a2008-10-20 05:42:331906<em>subsystem</em> are literally the same before and after the rebase
1907<em>subsystem</em> did.</p></div>
Junio C Hamano68cf15a2010-11-06 01:01:591908<div class="paragraph"><p>In that case, the fix is easy because <em>git rebase</em> knows to skip
Junio C Hamano7d06a8a2008-10-20 05:42:331909changes that are already present in the new upstream. So if you say
Junio C Hamano68cf15a2010-11-06 01:01:591910(assuming you&#8217;re on <em>topic</em>)</p></div>
Junio C Hamano7d06a8a2008-10-20 05:42:331911<div class="listingblock">
1912<div class="content">
Junio C Hamanoac12f0e2014-09-19 22:32:511913<pre><code> $ git rebase subsystem</code></pre>
Junio C Hamano7d06a8a2008-10-20 05:42:331914</div></div>
Junio C Hamano68cf15a2010-11-06 01:01:591915<div class="paragraph"><p>you will end up with the fixed history</p></div>
Junio C Hamano7d06a8a2008-10-20 05:42:331916<div class="listingblock">
1917<div class="content">
Junio C Hamanoac12f0e2014-09-19 22:32:511918<pre><code> o---o---o---o---o---o---o---o master
Junio C Hamano7d06a8a2008-10-20 05:42:331919 \
1920 o'--o'--o'--o'--o' subsystem
1921 \
Junio C Hamanoac12f0e2014-09-19 22:32:511922 *---*---* topic</code></pre>
Junio C Hamano7d06a8a2008-10-20 05:42:331923</div></div>
Junio C Hamano9d971152012-12-19 00:43:111924</div>
1925<div class="sect2">
1926<h3 id="_the_hard_case">The hard case</h3>
Junio C Hamano68cf15a2010-11-06 01:01:591927<div class="paragraph"><p>Things get more complicated if the <em>subsystem</em> changes do not exactly
Junio C Hamano7d06a8a2008-10-20 05:42:331928correspond to the ones before the rebase.</p></div>
1929<div class="admonitionblock">
1930<table><tr>
1931<td class="icon">
1932<div class="title">Note</div>
1933</td>
1934<td class="content">While an "easy case recovery" sometimes appears to be successful
1935 even in the hard case, it may have unintended consequences. For
Junio C Hamanoac12f0e2014-09-19 22:32:511936 example, a commit that was removed via <code>git rebase
1937 --interactive</code> will be <strong>resurrected</strong>!</td>
Junio C Hamano7d06a8a2008-10-20 05:42:331938</tr></table>
1939</div>
Junio C Hamano68cf15a2010-11-06 01:01:591940<div class="paragraph"><p>The idea is to manually tell <em>git rebase</em> "where the old <em>subsystem</em>
Junio C Hamano7d06a8a2008-10-20 05:42:331941ended and your <em>topic</em> began", that is, what the old merge-base
1942between them was. You will have to find a way to name the last commit
1943of the old <em>subsystem</em>, for example:</p></div>
Junio C Hamano68cf15a2010-11-06 01:01:591944<div class="ulist"><ul>
Junio C Hamano7d06a8a2008-10-20 05:42:331945<li>
1946<p>
Junio C Hamano1aa40d22010-01-21 17:46:431947With the <em>subsystem</em> reflog: after <em>git fetch</em>, the old tip of
Junio C Hamanoac12f0e2014-09-19 22:32:511948 <em>subsystem</em> is at <code>subsystem@{1}</code>. Subsequent fetches will
Junio C Hamanoa28a9202012-06-21 07:08:231949 increase the number. (See <a href="git-reflog.html">git-reflog(1)</a>.)
Junio C Hamano7d06a8a2008-10-20 05:42:331950</p>
1951</li>
1952<li>
1953<p>
1954Relative to the tip of <em>topic</em>: knowing that your <em>topic</em> has three
Junio C Hamanoac12f0e2014-09-19 22:32:511955 commits, the old tip of <em>subsystem</em> must be <code>topic~3</code>.
Junio C Hamano7d06a8a2008-10-20 05:42:331956</p>
1957</li>
1958</ul></div>
Junio C Hamanoac12f0e2014-09-19 22:32:511959<div class="paragraph"><p>You can then transplant the old <code>subsystem..topic</code> to the new tip by
Junio C Hamano7d06a8a2008-10-20 05:42:331960saying (for the reflog case, and assuming you are on <em>topic</em> already):</p></div>
1961<div class="listingblock">
1962<div class="content">
Junio C Hamanoac12f0e2014-09-19 22:32:511963<pre><code> $ git rebase --onto subsystem subsystem@{1}</code></pre>
Junio C Hamano7d06a8a2008-10-20 05:42:331964</div></div>
Junio C Hamano68cf15a2010-11-06 01:01:591965<div class="paragraph"><p>The ripple effect of a "hard case" recovery is especially bad:
Junio C Hamano7d06a8a2008-10-20 05:42:331966<em>everyone</em> downstream from <em>topic</em> will now have to perform a "hard
1967case" recovery too!</p></div>
1968</div>
Junio C Hamano9d971152012-12-19 00:43:111969</div>
1970</div>
1971<div class="sect1">
Junio C Hamanobb88cf42010-06-21 15:23:551972<h2 id="_bugs">BUGS</h2>
1973<div class="sectionbody">
Junio C Hamanoac12f0e2014-09-19 22:32:511974<div class="paragraph"><p>The todo list presented by <code>--preserve-merges --interactive</code> does not
Junio C Hamanobb88cf42010-06-21 15:23:551975represent the topology of the revision graph. Editing commits and
1976rewording their commit messages should work fine, but attempts to
1977reorder commits tend to produce counterintuitive results.</p></div>
Junio C Hamano68cf15a2010-11-06 01:01:591978<div class="paragraph"><p>For example, an attempt to rearrange</p></div>
Junio C Hamanobb88cf42010-06-21 15:23:551979<div class="listingblock">
1980<div class="content">
Junio C Hamanoac12f0e2014-09-19 22:32:511981<pre><code>1 --- 2 --- 3 --- 4 --- 5</code></pre>
Junio C Hamanobb88cf42010-06-21 15:23:551982</div></div>
Junio C Hamano68cf15a2010-11-06 01:01:591983<div class="paragraph"><p>to</p></div>
Junio C Hamanobb88cf42010-06-21 15:23:551984<div class="listingblock">
1985<div class="content">
Junio C Hamanoac12f0e2014-09-19 22:32:511986<pre><code>1 --- 2 --- 4 --- 3 --- 5</code></pre>
Junio C Hamanobb88cf42010-06-21 15:23:551987</div></div>
Junio C Hamano68cf15a2010-11-06 01:01:591988<div class="paragraph"><p>by moving the "pick 4" line will result in the following history:</p></div>
Junio C Hamanobb88cf42010-06-21 15:23:551989<div class="listingblock">
1990<div class="content">
Junio C Hamanoac12f0e2014-09-19 22:32:511991<pre><code> 3
Junio C Hamanobb88cf42010-06-21 15:23:551992 /
Junio C Hamanoac12f0e2014-09-19 22:32:5119931 --- 2 --- 4 --- 5</code></pre>
Junio C Hamanobb88cf42010-06-21 15:23:551994</div></div>
1995</div>
Junio C Hamano9d971152012-12-19 00:43:111996</div>
1997<div class="sect1">
Junio C Hamanoba4b9282008-07-06 05:20:311998<h2 id="_git">GIT</h2>
Junio C Hamano1a4e8412005-12-27 08:17:231999<div class="sectionbody">
Junio C Hamanoa28a9202012-06-21 07:08:232000<div class="paragraph"><p>Part of the <a href="git.html">git(1)</a> suite</p></div>
Junio C Hamano1a4e8412005-12-27 08:17:232001</div>
Junio C Hamano7bd050f2011-09-22 06:32:222002</div>
Junio C Hamano9d971152012-12-19 00:43:112003</div>
Junio C Hamano7bd050f2011-09-22 06:32:222004<div id="footnotes"><hr /></div>
Junio C Hamano1a4e8412005-12-27 08:17:232005<div id="footer">
2006<div id="footer-text">
Junio C Hamano1eb56092015-10-05 20:39:532007Last updated 2015-10-05 13:38:43 PDT
Junio C Hamano1a4e8412005-12-27 08:17:232008</div>
2009</div>
2010</body>
2011</html>