Autogenerated HTML docs for v2.42.0-526-g3130c1
[git-htmldocs.git] / git-rebase.html
blob93dbedc4d115fad13aa6be754859cd696e11ecb4
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
3 "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
4 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
5 <head>
6 <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" />
7 <meta name="generator" content="AsciiDoc 10.2.0" />
8 <title>git-rebase(1)</title>
9 <style type="text/css">
10 /* Shared CSS for AsciiDoc xhtml11 and html5 backends */
12 /* Default font. */
13 body {
14 font-family: Georgia,serif;
17 /* Title font. */
18 h1, h2, h3, h4, h5, h6,
19 div.title, caption.title,
20 thead, p.table.header,
21 #toctitle,
22 #author, #revnumber, #revdate, #revremark,
23 #footer {
24 font-family: Arial,Helvetica,sans-serif;
27 body {
28 margin: 1em 5% 1em 5%;
31 a {
32 color: blue;
33 text-decoration: underline;
35 a:visited {
36 color: fuchsia;
39 em {
40 font-style: italic;
41 color: navy;
44 strong {
45 font-weight: bold;
46 color: #083194;
49 h1, h2, h3, h4, h5, h6 {
50 color: #527bbd;
51 margin-top: 1.2em;
52 margin-bottom: 0.5em;
53 line-height: 1.3;
56 h1, h2, h3 {
57 border-bottom: 2px solid silver;
59 h2 {
60 padding-top: 0.5em;
62 h3 {
63 float: left;
65 h3 + * {
66 clear: left;
68 h5 {
69 font-size: 1.0em;
72 div.sectionbody {
73 margin-left: 0;
76 hr {
77 border: 1px solid silver;
80 p {
81 margin-top: 0.5em;
82 margin-bottom: 0.5em;
85 ul, ol, li > p {
86 margin-top: 0;
88 ul > li { color: #aaa; }
89 ul > li > * { color: black; }
91 .monospaced, code, pre {
92 font-family: "Courier New", Courier, monospace;
93 font-size: inherit;
94 color: navy;
95 padding: 0;
96 margin: 0;
98 pre {
99 white-space: pre-wrap;
102 #author {
103 color: #527bbd;
104 font-weight: bold;
105 font-size: 1.1em;
107 #email {
109 #revnumber, #revdate, #revremark {
112 #footer {
113 font-size: small;
114 border-top: 2px solid silver;
115 padding-top: 0.5em;
116 margin-top: 4.0em;
118 #footer-text {
119 float: left;
120 padding-bottom: 0.5em;
122 #footer-badges {
123 float: right;
124 padding-bottom: 0.5em;
127 #preamble {
128 margin-top: 1.5em;
129 margin-bottom: 1.5em;
131 div.imageblock, div.exampleblock, div.verseblock,
132 div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock,
133 div.admonitionblock {
134 margin-top: 1.0em;
135 margin-bottom: 1.5em;
137 div.admonitionblock {
138 margin-top: 2.0em;
139 margin-bottom: 2.0em;
140 margin-right: 10%;
141 color: #606060;
144 div.content { /* Block element content. */
145 padding: 0;
148 /* Block element titles. */
149 div.title, caption.title {
150 color: #527bbd;
151 font-weight: bold;
152 text-align: left;
153 margin-top: 1.0em;
154 margin-bottom: 0.5em;
156 div.title + * {
157 margin-top: 0;
160 td div.title:first-child {
161 margin-top: 0.0em;
163 div.content div.title:first-child {
164 margin-top: 0.0em;
166 div.content + div.title {
167 margin-top: 0.0em;
170 div.sidebarblock > div.content {
171 background: #ffffee;
172 border: 1px solid #dddddd;
173 border-left: 4px solid #f0f0f0;
174 padding: 0.5em;
177 div.listingblock > div.content {
178 border: 1px solid #dddddd;
179 border-left: 5px solid #f0f0f0;
180 background: #f8f8f8;
181 padding: 0.5em;
184 div.quoteblock, div.verseblock {
185 padding-left: 1.0em;
186 margin-left: 1.0em;
187 margin-right: 10%;
188 border-left: 5px solid #f0f0f0;
189 color: #888;
192 div.quoteblock > div.attribution {
193 padding-top: 0.5em;
194 text-align: right;
197 div.verseblock > pre.content {
198 font-family: inherit;
199 font-size: inherit;
201 div.verseblock > div.attribution {
202 padding-top: 0.75em;
203 text-align: left;
205 /* DEPRECATED: Pre version 8.2.7 verse style literal block. */
206 div.verseblock + div.attribution {
207 text-align: left;
210 div.admonitionblock .icon {
211 vertical-align: top;
212 font-size: 1.1em;
213 font-weight: bold;
214 text-decoration: underline;
215 color: #527bbd;
216 padding-right: 0.5em;
218 div.admonitionblock td.content {
219 padding-left: 0.5em;
220 border-left: 3px solid #dddddd;
223 div.exampleblock > div.content {
224 border-left: 3px solid #dddddd;
225 padding-left: 0.5em;
228 div.imageblock div.content { padding-left: 0; }
229 span.image img { border-style: none; vertical-align: text-bottom; }
230 a.image:visited { color: white; }
232 dl {
233 margin-top: 0.8em;
234 margin-bottom: 0.8em;
236 dt {
237 margin-top: 0.5em;
238 margin-bottom: 0;
239 font-style: normal;
240 color: navy;
242 dd > *:first-child {
243 margin-top: 0.1em;
246 ul, ol {
247 list-style-position: outside;
249 ol.arabic {
250 list-style-type: decimal;
252 ol.loweralpha {
253 list-style-type: lower-alpha;
255 ol.upperalpha {
256 list-style-type: upper-alpha;
258 ol.lowerroman {
259 list-style-type: lower-roman;
261 ol.upperroman {
262 list-style-type: upper-roman;
265 div.compact ul, div.compact ol,
266 div.compact p, div.compact p,
267 div.compact div, div.compact div {
268 margin-top: 0.1em;
269 margin-bottom: 0.1em;
272 tfoot {
273 font-weight: bold;
275 td > div.verse {
276 white-space: pre;
279 div.hdlist {
280 margin-top: 0.8em;
281 margin-bottom: 0.8em;
283 div.hdlist tr {
284 padding-bottom: 15px;
286 dt.hdlist1.strong, td.hdlist1.strong {
287 font-weight: bold;
289 td.hdlist1 {
290 vertical-align: top;
291 font-style: normal;
292 padding-right: 0.8em;
293 color: navy;
295 td.hdlist2 {
296 vertical-align: top;
298 div.hdlist.compact tr {
299 margin: 0;
300 padding-bottom: 0;
303 .comment {
304 background: yellow;
307 .footnote, .footnoteref {
308 font-size: 0.8em;
311 span.footnote, span.footnoteref {
312 vertical-align: super;
315 #footnotes {
316 margin: 20px 0 20px 0;
317 padding: 7px 0 0 0;
320 #footnotes div.footnote {
321 margin: 0 0 5px 0;
324 #footnotes hr {
325 border: none;
326 border-top: 1px solid silver;
327 height: 1px;
328 text-align: left;
329 margin-left: 0;
330 width: 20%;
331 min-width: 100px;
334 div.colist td {
335 padding-right: 0.5em;
336 padding-bottom: 0.3em;
337 vertical-align: top;
339 div.colist td img {
340 margin-top: 0.3em;
343 @media print {
344 #footer-badges { display: none; }
347 #toc {
348 margin-bottom: 2.5em;
351 #toctitle {
352 color: #527bbd;
353 font-size: 1.1em;
354 font-weight: bold;
355 margin-top: 1.0em;
356 margin-bottom: 0.1em;
359 div.toclevel0, div.toclevel1, div.toclevel2, div.toclevel3, div.toclevel4 {
360 margin-top: 0;
361 margin-bottom: 0;
363 div.toclevel2 {
364 margin-left: 2em;
365 font-size: 0.9em;
367 div.toclevel3 {
368 margin-left: 4em;
369 font-size: 0.9em;
371 div.toclevel4 {
372 margin-left: 6em;
373 font-size: 0.9em;
376 span.aqua { color: aqua; }
377 span.black { color: black; }
378 span.blue { color: blue; }
379 span.fuchsia { color: fuchsia; }
380 span.gray { color: gray; }
381 span.green { color: green; }
382 span.lime { color: lime; }
383 span.maroon { color: maroon; }
384 span.navy { color: navy; }
385 span.olive { color: olive; }
386 span.purple { color: purple; }
387 span.red { color: red; }
388 span.silver { color: silver; }
389 span.teal { color: teal; }
390 span.white { color: white; }
391 span.yellow { color: yellow; }
393 span.aqua-background { background: aqua; }
394 span.black-background { background: black; }
395 span.blue-background { background: blue; }
396 span.fuchsia-background { background: fuchsia; }
397 span.gray-background { background: gray; }
398 span.green-background { background: green; }
399 span.lime-background { background: lime; }
400 span.maroon-background { background: maroon; }
401 span.navy-background { background: navy; }
402 span.olive-background { background: olive; }
403 span.purple-background { background: purple; }
404 span.red-background { background: red; }
405 span.silver-background { background: silver; }
406 span.teal-background { background: teal; }
407 span.white-background { background: white; }
408 span.yellow-background { background: yellow; }
410 span.big { font-size: 2em; }
411 span.small { font-size: 0.6em; }
413 span.underline { text-decoration: underline; }
414 span.overline { text-decoration: overline; }
415 span.line-through { text-decoration: line-through; }
417 div.unbreakable { page-break-inside: avoid; }
421 * xhtml11 specific
423 * */
425 div.tableblock {
426 margin-top: 1.0em;
427 margin-bottom: 1.5em;
429 div.tableblock > table {
430 border: 3px solid #527bbd;
432 thead, p.table.header {
433 font-weight: bold;
434 color: #527bbd;
436 p.table {
437 margin-top: 0;
439 /* Because the table frame attribute is overridden by CSS in most browsers. */
440 div.tableblock > table[frame="void"] {
441 border-style: none;
443 div.tableblock > table[frame="hsides"] {
444 border-left-style: none;
445 border-right-style: none;
447 div.tableblock > table[frame="vsides"] {
448 border-top-style: none;
449 border-bottom-style: none;
454 * html5 specific
456 * */
458 table.tableblock {
459 margin-top: 1.0em;
460 margin-bottom: 1.5em;
462 thead, p.tableblock.header {
463 font-weight: bold;
464 color: #527bbd;
466 p.tableblock {
467 margin-top: 0;
469 table.tableblock {
470 border-width: 3px;
471 border-spacing: 0px;
472 border-style: solid;
473 border-color: #527bbd;
474 border-collapse: collapse;
476 th.tableblock, td.tableblock {
477 border-width: 1px;
478 padding: 4px;
479 border-style: solid;
480 border-color: #527bbd;
483 table.tableblock.frame-topbot {
484 border-left-style: hidden;
485 border-right-style: hidden;
487 table.tableblock.frame-sides {
488 border-top-style: hidden;
489 border-bottom-style: hidden;
491 table.tableblock.frame-none {
492 border-style: hidden;
495 th.tableblock.halign-left, td.tableblock.halign-left {
496 text-align: left;
498 th.tableblock.halign-center, td.tableblock.halign-center {
499 text-align: center;
501 th.tableblock.halign-right, td.tableblock.halign-right {
502 text-align: right;
505 th.tableblock.valign-top, td.tableblock.valign-top {
506 vertical-align: top;
508 th.tableblock.valign-middle, td.tableblock.valign-middle {
509 vertical-align: middle;
511 th.tableblock.valign-bottom, td.tableblock.valign-bottom {
512 vertical-align: bottom;
517 * manpage specific
519 * */
521 body.manpage h1 {
522 padding-top: 0.5em;
523 padding-bottom: 0.5em;
524 border-top: 2px solid silver;
525 border-bottom: 2px solid silver;
527 body.manpage h2 {
528 border-style: none;
530 body.manpage div.sectionbody {
531 margin-left: 3em;
534 @media print {
535 body.manpage div#toc { display: none; }
539 </style>
540 <script type="text/javascript">
541 /*<![CDATA[*/
542 var asciidoc = { // Namespace.
544 /////////////////////////////////////////////////////////////////////
545 // Table Of Contents generator
546 /////////////////////////////////////////////////////////////////////
548 /* Author: Mihai Bazon, September 2002
549 * http://students.infoiasi.ro/~mishoo
551 * Table Of Content generator
552 * Version: 0.4
554 * Feel free to use this script under the terms of the GNU General Public
555 * License, as long as you do not remove or alter this notice.
558 /* modified by Troy D. Hanson, September 2006. License: GPL */
559 /* modified by Stuart Rackham, 2006, 2009. License: GPL */
561 // toclevels = 1..4.
562 toc: function (toclevels) {
564 function getText(el) {
565 var text = "";
566 for (var i = el.firstChild; i != null; i = i.nextSibling) {
567 if (i.nodeType == 3 /* Node.TEXT_NODE */) // IE doesn't speak constants.
568 text += i.data;
569 else if (i.firstChild != null)
570 text += getText(i);
572 return text;
575 function TocEntry(el, text, toclevel) {
576 this.element = el;
577 this.text = text;
578 this.toclevel = toclevel;
581 function tocEntries(el, toclevels) {
582 var result = new Array;
583 var re = new RegExp('[hH]([1-'+(toclevels+1)+'])');
584 // Function that scans the DOM tree for header elements (the DOM2
585 // nodeIterator API would be a better technique but not supported by all
586 // browsers).
587 var iterate = function (el) {
588 for (var i = el.firstChild; i != null; i = i.nextSibling) {
589 if (i.nodeType == 1 /* Node.ELEMENT_NODE */) {
590 var mo = re.exec(i.tagName);
591 if (mo && (i.getAttribute("class") || i.getAttribute("className")) != "float") {
592 result[result.length] = new TocEntry(i, getText(i), mo[1]-1);
594 iterate(i);
598 iterate(el);
599 return result;
602 var toc = document.getElementById("toc");
603 if (!toc) {
604 return;
607 // Delete existing TOC entries in case we're reloading the TOC.
608 var tocEntriesToRemove = [];
609 var i;
610 for (i = 0; i < toc.childNodes.length; i++) {
611 var entry = toc.childNodes[i];
612 if (entry.nodeName.toLowerCase() == 'div'
613 && entry.getAttribute("class")
614 && entry.getAttribute("class").match(/^toclevel/))
615 tocEntriesToRemove.push(entry);
617 for (i = 0; i < tocEntriesToRemove.length; i++) {
618 toc.removeChild(tocEntriesToRemove[i]);
621 // Rebuild TOC entries.
622 var entries = tocEntries(document.getElementById("content"), toclevels);
623 for (var i = 0; i < entries.length; ++i) {
624 var entry = entries[i];
625 if (entry.element.id == "")
626 entry.element.id = "_toc_" + i;
627 var a = document.createElement("a");
628 a.href = "#" + entry.element.id;
629 a.appendChild(document.createTextNode(entry.text));
630 var div = document.createElement("div");
631 div.appendChild(a);
632 div.className = "toclevel" + entry.toclevel;
633 toc.appendChild(div);
635 if (entries.length == 0)
636 toc.parentNode.removeChild(toc);
640 /////////////////////////////////////////////////////////////////////
641 // Footnotes generator
642 /////////////////////////////////////////////////////////////////////
644 /* Based on footnote generation code from:
645 * http://www.brandspankingnew.net/archive/2005/07/format_footnote.html
648 footnotes: function () {
649 // Delete existing footnote entries in case we're reloading the footnodes.
650 var i;
651 var noteholder = document.getElementById("footnotes");
652 if (!noteholder) {
653 return;
655 var entriesToRemove = [];
656 for (i = 0; i < noteholder.childNodes.length; i++) {
657 var entry = noteholder.childNodes[i];
658 if (entry.nodeName.toLowerCase() == 'div' && entry.getAttribute("class") == "footnote")
659 entriesToRemove.push(entry);
661 for (i = 0; i < entriesToRemove.length; i++) {
662 noteholder.removeChild(entriesToRemove[i]);
665 // Rebuild footnote entries.
666 var cont = document.getElementById("content");
667 var spans = cont.getElementsByTagName("span");
668 var refs = {};
669 var n = 0;
670 for (i=0; i<spans.length; i++) {
671 if (spans[i].className == "footnote") {
672 n++;
673 var note = spans[i].getAttribute("data-note");
674 if (!note) {
675 // Use [\s\S] in place of . so multi-line matches work.
676 // Because JavaScript has no s (dotall) regex flag.
677 note = spans[i].innerHTML.match(/\s*\[([\s\S]*)]\s*/)[1];
678 spans[i].innerHTML =
679 "[<a id='_footnoteref_" + n + "' href='#_footnote_" + n +
680 "' title='View footnote' class='footnote'>" + n + "</a>]";
681 spans[i].setAttribute("data-note", note);
683 noteholder.innerHTML +=
684 "<div class='footnote' id='_footnote_" + n + "'>" +
685 "<a href='#_footnoteref_" + n + "' title='Return to text'>" +
686 n + "</a>. " + note + "</div>";
687 var id =spans[i].getAttribute("id");
688 if (id != null) refs["#"+id] = n;
691 if (n == 0)
692 noteholder.parentNode.removeChild(noteholder);
693 else {
694 // Process footnoterefs.
695 for (i=0; i<spans.length; i++) {
696 if (spans[i].className == "footnoteref") {
697 var href = spans[i].getElementsByTagName("a")[0].getAttribute("href");
698 href = href.match(/#.*/)[0]; // Because IE return full URL.
699 n = refs[href];
700 spans[i].innerHTML =
701 "[<a href='#_footnote_" + n +
702 "' title='View footnote' class='footnote'>" + n + "</a>]";
708 install: function(toclevels) {
709 var timerId;
711 function reinstall() {
712 asciidoc.footnotes();
713 if (toclevels) {
714 asciidoc.toc(toclevels);
718 function reinstallAndRemoveTimer() {
719 clearInterval(timerId);
720 reinstall();
723 timerId = setInterval(reinstall, 500);
724 if (document.addEventListener)
725 document.addEventListener("DOMContentLoaded", reinstallAndRemoveTimer, false);
726 else
727 window.onload = reinstallAndRemoveTimer;
731 asciidoc.install();
732 /*]]>*/
733 </script>
734 </head>
735 <body class="manpage">
736 <div id="header">
737 <h1>
738 git-rebase(1) Manual Page
739 </h1>
740 <h2>NAME</h2>
741 <div class="sectionbody">
742 <p>git-rebase -
743 Reapply commits on top of another base tip
744 </p>
745 </div>
746 </div>
747 <div id="content">
748 <div class="sect1">
749 <h2 id="_synopsis">SYNOPSIS</h2>
750 <div class="sectionbody">
751 <div class="verseblock">
752 <pre class="content"><em>git rebase</em> [-i | --interactive] [&lt;options&gt;] [--exec &lt;cmd&gt;]
753 [--onto &lt;newbase&gt; | --keep-base] [&lt;upstream&gt; [&lt;branch&gt;]]
754 <em>git rebase</em> [-i | --interactive] [&lt;options&gt;] [--exec &lt;cmd&gt;] [--onto &lt;newbase&gt;]
755 --root [&lt;branch&gt;]
756 <em>git rebase</em> (--continue | --skip | --abort | --quit | --edit-todo | --show-current-patch)</pre>
757 <div class="attribution">
758 </div></div>
759 </div>
760 </div>
761 <div class="sect1">
762 <h2 id="_description">DESCRIPTION</h2>
763 <div class="sectionbody">
764 <div class="paragraph"><p>If <code>&lt;branch&gt;</code> is specified, <code>git rebase</code> will perform an automatic
765 <code>git switch &lt;branch&gt;</code> before doing anything else. Otherwise
766 it remains on the current branch.</p></div>
767 <div class="paragraph"><p>If <code>&lt;upstream&gt;</code> is not specified, the upstream configured in
768 <code>branch.&lt;name&gt;.remote</code> and <code>branch.&lt;name&gt;.merge</code> options will be used (see
769 <a href="git-config.html">git-config(1)</a> for details) and the <code>--fork-point</code> option is
770 assumed. If you are currently not on any branch or if the current
771 branch does not have a configured upstream, the rebase will abort.</p></div>
772 <div class="paragraph"><p>All changes made by commits in the current branch but that are not
773 in <code>&lt;upstream&gt;</code> are saved to a temporary area. This is the same set
774 of commits that would be shown by <code>git log &lt;upstream&gt;..HEAD</code>; or by
775 <code>git log 'fork_point'..HEAD</code>, if <code>--fork-point</code> is active (see the
776 description on <code>--fork-point</code> below); or by <code>git log HEAD</code>, if the
777 <code>--root</code> option is specified.</p></div>
778 <div class="paragraph"><p>The current branch is reset to <code>&lt;upstream&gt;</code> or <code>&lt;newbase&gt;</code> if the
779 <code>--onto</code> option was supplied. This has the exact same effect as
780 <code>git reset --hard &lt;upstream&gt;</code> (or <code>&lt;newbase&gt;</code>). <code>ORIG_HEAD</code> is set
781 to point at the tip of the branch before the reset.</p></div>
782 <div class="admonitionblock">
783 <table><tr>
784 <td class="icon">
785 <div class="title">Note</div>
786 </td>
787 <td class="content"><code>ORIG_HEAD</code> is not guaranteed to still point to the previous branch tip
788 at the end of the rebase if other commands that write that pseudo-ref
789 (e.g. <code>git reset</code>) are used during the rebase. The previous branch tip,
790 however, is accessible using the reflog of the current branch
791 (i.e. <code>@{1}</code>, see <a href="gitrevisions.html">gitrevisions(7)</a>).</td>
792 </tr></table>
793 </div>
794 <div class="paragraph"><p>The commits that were previously saved into the temporary area are
795 then reapplied to the current branch, one by one, in order. Note that
796 any commits in <code>HEAD</code> which introduce the same textual changes as a commit
797 in <code>HEAD..&lt;upstream&gt;</code> are omitted (i.e., a patch already accepted upstream
798 with a different commit message or timestamp will be skipped).</p></div>
799 <div class="paragraph"><p>It is possible that a merge failure will prevent this process from being
800 completely automatic. You will have to resolve any such merge failure
801 and run <code>git rebase --continue</code>. Another option is to bypass the commit
802 that caused the merge failure with <code>git rebase --skip</code>. To check out the
803 original <code>&lt;branch&gt;</code> and remove the <code>.git/rebase-apply</code> working files, use
804 the command <code>git rebase --abort</code> instead.</p></div>
805 <div class="paragraph"><p>Assume the following history exists and the current branch is "topic":</p></div>
806 <div class="listingblock">
807 <div class="content">
808 <pre><code> A---B---C topic
810 D---E---F---G master</code></pre>
811 </div></div>
812 <div class="paragraph"><p>From this point, the result of either of the following commands:</p></div>
813 <div class="literalblock">
814 <div class="content">
815 <pre><code>git rebase master
816 git rebase master topic</code></pre>
817 </div></div>
818 <div class="paragraph"><p>would be:</p></div>
819 <div class="listingblock">
820 <div class="content">
821 <pre><code> A'--B'--C' topic
823 D---E---F---G master</code></pre>
824 </div></div>
825 <div class="paragraph"><p><strong>NOTE:</strong> The latter form is just a short-hand of <code>git checkout topic</code>
826 followed by <code>git rebase master</code>. When rebase exits <code>topic</code> will
827 remain the checked-out branch.</p></div>
828 <div class="paragraph"><p>If the upstream branch already contains a change you have made (e.g.,
829 because you mailed a patch which was applied upstream), then that commit
830 will be skipped and warnings will be issued (if the <em>merge</em> backend is
831 used). For example, running <code>git rebase master</code> on the following
832 history (in which <code>A'</code> and <code>A</code> introduce the same set of changes, but
833 have different committer information):</p></div>
834 <div class="listingblock">
835 <div class="content">
836 <pre><code> A---B---C topic
838 D---E---A'---F master</code></pre>
839 </div></div>
840 <div class="paragraph"><p>will result in:</p></div>
841 <div class="listingblock">
842 <div class="content">
843 <pre><code> B'---C' topic
845 D---E---A'---F master</code></pre>
846 </div></div>
847 <div class="paragraph"><p>Here is how you would transplant a topic branch based on one
848 branch to another, to pretend that you forked the topic branch
849 from the latter branch, using <code>rebase --onto</code>.</p></div>
850 <div class="paragraph"><p>First let&#8217;s assume your <em>topic</em> is based on branch <em>next</em>.
851 For example, a feature developed in <em>topic</em> depends on some
852 functionality which is found in <em>next</em>.</p></div>
853 <div class="listingblock">
854 <div class="content">
855 <pre><code> o---o---o---o---o master
857 o---o---o---o---o next
859 o---o---o topic</code></pre>
860 </div></div>
861 <div class="paragraph"><p>We want to make <em>topic</em> forked from branch <em>master</em>; for example,
862 because the functionality on which <em>topic</em> depends was merged into the
863 more stable <em>master</em> branch. We want our tree to look like this:</p></div>
864 <div class="listingblock">
865 <div class="content">
866 <pre><code> o---o---o---o---o master
868 | o'--o'--o' topic
870 o---o---o---o---o next</code></pre>
871 </div></div>
872 <div class="paragraph"><p>We can get this using the following command:</p></div>
873 <div class="literalblock">
874 <div class="content">
875 <pre><code>git rebase --onto master next topic</code></pre>
876 </div></div>
877 <div class="paragraph"><p>Another example of --onto option is to rebase part of a
878 branch. If we have the following situation:</p></div>
879 <div class="listingblock">
880 <div class="content">
881 <pre><code> H---I---J topicB
883 E---F---G topicA
885 A---B---C---D master</code></pre>
886 </div></div>
887 <div class="paragraph"><p>then the command</p></div>
888 <div class="literalblock">
889 <div class="content">
890 <pre><code>git rebase --onto master topicA topicB</code></pre>
891 </div></div>
892 <div class="paragraph"><p>would result in:</p></div>
893 <div class="listingblock">
894 <div class="content">
895 <pre><code> H'--I'--J' topicB
897 | E---F---G topicA
899 A---B---C---D master</code></pre>
900 </div></div>
901 <div class="paragraph"><p>This is useful when topicB does not depend on topicA.</p></div>
902 <div class="paragraph"><p>A range of commits could also be removed with rebase. If we have
903 the following situation:</p></div>
904 <div class="listingblock">
905 <div class="content">
906 <pre><code> E---F---G---H---I---J topicA</code></pre>
907 </div></div>
908 <div class="paragraph"><p>then the command</p></div>
909 <div class="literalblock">
910 <div class="content">
911 <pre><code>git rebase --onto topicA~5 topicA~3 topicA</code></pre>
912 </div></div>
913 <div class="paragraph"><p>would result in the removal of commits F and G:</p></div>
914 <div class="listingblock">
915 <div class="content">
916 <pre><code> E---H'---I'---J' topicA</code></pre>
917 </div></div>
918 <div class="paragraph"><p>This is useful if F and G were flawed in some way, or should not be
919 part of topicA. Note that the argument to <code>--onto</code> and the <code>&lt;upstream&gt;</code>
920 parameter can be any valid commit-ish.</p></div>
921 <div class="paragraph"><p>In case of conflict, <code>git rebase</code> will stop at the first problematic commit
922 and leave conflict markers in the tree. You can use <code>git diff</code> to locate
923 the markers (&lt;&lt;&lt;&lt;&lt;&lt;) and make edits to resolve the conflict. For each
924 file you edit, you need to tell Git that the conflict has been resolved,
925 typically this would be done with</p></div>
926 <div class="literalblock">
927 <div class="content">
928 <pre><code>git add &lt;filename&gt;</code></pre>
929 </div></div>
930 <div class="paragraph"><p>After resolving the conflict manually and updating the index with the
931 desired resolution, you can continue the rebasing process with</p></div>
932 <div class="literalblock">
933 <div class="content">
934 <pre><code>git rebase --continue</code></pre>
935 </div></div>
936 <div class="paragraph"><p>Alternatively, you can undo the <em>git rebase</em> with</p></div>
937 <div class="literalblock">
938 <div class="content">
939 <pre><code>git rebase --abort</code></pre>
940 </div></div>
941 </div>
942 </div>
943 <div class="sect1">
944 <h2 id="_mode_options">MODE OPTIONS</h2>
945 <div class="sectionbody">
946 <div class="paragraph"><p>The options in this section cannot be used with any other option,
947 including not with each other:</p></div>
948 <div class="dlist"><dl>
949 <dt class="hdlist1">
950 --continue
951 </dt>
952 <dd>
954 Restart the rebasing process after having resolved a merge conflict.
955 </p>
956 </dd>
957 <dt class="hdlist1">
958 --skip
959 </dt>
960 <dd>
962 Restart the rebasing process by skipping the current patch.
963 </p>
964 </dd>
965 <dt class="hdlist1">
966 --abort
967 </dt>
968 <dd>
970 Abort the rebase operation and reset HEAD to the original
971 branch. If <code>&lt;branch&gt;</code> was provided when the rebase operation was
972 started, then <code>HEAD</code> will be reset to <code>&lt;branch&gt;</code>. Otherwise <code>HEAD</code>
973 will be reset to where it was when the rebase operation was
974 started.
975 </p>
976 </dd>
977 <dt class="hdlist1">
978 --quit
979 </dt>
980 <dd>
982 Abort the rebase operation but <code>HEAD</code> is not reset back to the
983 original branch. The index and working tree are also left
984 unchanged as a result. If a temporary stash entry was created
985 using <code>--autostash</code>, it will be saved to the stash list.
986 </p>
987 </dd>
988 <dt class="hdlist1">
989 --edit-todo
990 </dt>
991 <dd>
993 Edit the todo list during an interactive rebase.
994 </p>
995 </dd>
996 <dt class="hdlist1">
997 --show-current-patch
998 </dt>
999 <dd>
1001 Show the current patch in an interactive rebase or when rebase
1002 is stopped because of conflicts. This is the equivalent of
1003 <code>git show REBASE_HEAD</code>.
1004 </p>
1005 </dd>
1006 </dl></div>
1007 </div>
1008 </div>
1009 <div class="sect1">
1010 <h2 id="_options">OPTIONS</h2>
1011 <div class="sectionbody">
1012 <div class="dlist"><dl>
1013 <dt class="hdlist1">
1014 --onto &lt;newbase&gt;
1015 </dt>
1016 <dd>
1018 Starting point at which to create the new commits. If the
1019 <code>--onto</code> option is not specified, the starting point is
1020 <code>&lt;upstream&gt;</code>. May be any valid commit, and not just an
1021 existing branch name.
1022 </p>
1023 <div class="paragraph"><p>As a special case, you may use "A...B" as a shortcut for the
1024 merge base of A and B if there is exactly one merge base. You can
1025 leave out at most one of A and B, in which case it defaults to HEAD.</p></div>
1026 </dd>
1027 <dt class="hdlist1">
1028 --keep-base
1029 </dt>
1030 <dd>
1032 Set the starting point at which to create the new commits to the
1033 merge base of <code>&lt;upstream&gt;</code> and <code>&lt;branch&gt;</code>. Running
1034 <code>git rebase --keep-base &lt;upstream&gt; &lt;branch&gt;</code> is equivalent to
1035 running
1036 <code>git rebase --reapply-cherry-picks --no-fork-point --onto &lt;upstream&gt;...&lt;branch&gt; &lt;upstream&gt; &lt;branch&gt;</code>.
1037 </p>
1038 <div class="paragraph"><p>This option is useful in the case where one is developing a feature on
1039 top of an upstream branch. While the feature is being worked on, the
1040 upstream branch may advance and it may not be the best idea to keep
1041 rebasing on top of the upstream but to keep the base commit as-is. As
1042 the base commit is unchanged this option implies <code>--reapply-cherry-picks</code>
1043 to avoid losing commits.</p></div>
1044 <div class="paragraph"><p>Although both this option and <code>--fork-point</code> find the merge base between
1045 <code>&lt;upstream&gt;</code> and <code>&lt;branch&gt;</code>, this option uses the merge base as the <em>starting
1046 point</em> on which new commits will be created, whereas <code>--fork-point</code> uses
1047 the merge base to determine the <em>set of commits</em> which will be rebased.</p></div>
1048 <div class="paragraph"><p>See also INCOMPATIBLE OPTIONS below.</p></div>
1049 </dd>
1050 <dt class="hdlist1">
1051 &lt;upstream&gt;
1052 </dt>
1053 <dd>
1055 Upstream branch to compare against. May be any valid commit,
1056 not just an existing branch name. Defaults to the configured
1057 upstream for the current branch.
1058 </p>
1059 </dd>
1060 <dt class="hdlist1">
1061 &lt;branch&gt;
1062 </dt>
1063 <dd>
1065 Working branch; defaults to <code>HEAD</code>.
1066 </p>
1067 </dd>
1068 <dt class="hdlist1">
1069 --apply
1070 </dt>
1071 <dd>
1073 Use applying strategies to rebase (calling <code>git-am</code>
1074 internally). This option may become a no-op in the future
1075 once the merge backend handles everything the apply one does.
1076 </p>
1077 <div class="paragraph"><p>See also INCOMPATIBLE OPTIONS below.</p></div>
1078 </dd>
1079 <dt class="hdlist1">
1080 --empty={drop,keep,ask}
1081 </dt>
1082 <dd>
1084 How to handle commits that are not empty to start and are not
1085 clean cherry-picks of any upstream commit, but which become
1086 empty after rebasing (because they contain a subset of already
1087 upstream changes). With drop (the default), commits that
1088 become empty are dropped. With keep, such commits are kept.
1089 With ask (implied by <code>--interactive</code>), the rebase will halt when
1090 an empty commit is applied allowing you to choose whether to
1091 drop it, edit files more, or just commit the empty changes.
1092 Other options, like <code>--exec</code>, will use the default of drop unless
1093 <code>-i</code>/<code>--interactive</code> is explicitly specified.
1094 </p>
1095 <div class="paragraph"><p>Note that commits which start empty are kept (unless <code>--no-keep-empty</code>
1096 is specified), and commits which are clean cherry-picks (as determined
1097 by <code>git log --cherry-mark ...</code>) are detected and dropped as a
1098 preliminary step (unless <code>--reapply-cherry-picks</code> or <code>--keep-base</code> is
1099 passed).</p></div>
1100 <div class="paragraph"><p>See also INCOMPATIBLE OPTIONS below.</p></div>
1101 </dd>
1102 <dt class="hdlist1">
1103 --no-keep-empty
1104 </dt>
1105 <dt class="hdlist1">
1106 --keep-empty
1107 </dt>
1108 <dd>
1110 Do not keep commits that start empty before the rebase
1111 (i.e. that do not change anything from its parent) in the
1112 result. The default is to keep commits which start empty,
1113 since creating such commits requires passing the <code>--allow-empty</code>
1114 override flag to <code>git commit</code>, signifying that a user is very
1115 intentionally creating such a commit and thus wants to keep
1117 </p>
1118 <div class="paragraph"><p>Usage of this flag will probably be rare, since you can get rid of
1119 commits that start empty by just firing up an interactive rebase and
1120 removing the lines corresponding to the commits you don&#8217;t want. This
1121 flag exists as a convenient shortcut, such as for cases where external
1122 tools generate many empty commits and you want them all removed.</p></div>
1123 <div class="paragraph"><p>For commits which do not start empty but become empty after rebasing,
1124 see the <code>--empty</code> flag.</p></div>
1125 <div class="paragraph"><p>See also INCOMPATIBLE OPTIONS below.</p></div>
1126 </dd>
1127 <dt class="hdlist1">
1128 --reapply-cherry-picks
1129 </dt>
1130 <dt class="hdlist1">
1131 --no-reapply-cherry-picks
1132 </dt>
1133 <dd>
1135 Reapply all clean cherry-picks of any upstream commit instead
1136 of preemptively dropping them. (If these commits then become
1137 empty after rebasing, because they contain a subset of already
1138 upstream changes, the behavior towards them is controlled by
1139 the <code>--empty</code> flag.)
1140 </p>
1141 <div class="paragraph"><p>In the absence of <code>--keep-base</code> (or if <code>--no-reapply-cherry-picks</code> is
1142 given), these commits will be automatically dropped. Because this
1143 necessitates reading all upstream commits, this can be expensive in
1144 repositories with a large number of upstream commits that need to be
1145 read. When using the <em>merge</em> backend, warnings will be issued for each
1146 dropped commit (unless <code>--quiet</code> is given). Advice will also be issued
1147 unless <code>advice.skippedCherryPicks</code> is set to false (see
1148 <a href="git-config.html">git-config(1)</a>).</p></div>
1149 <div class="paragraph"><p><code>--reapply-cherry-picks</code> allows rebase to forgo reading all upstream
1150 commits, potentially improving performance.</p></div>
1151 <div class="paragraph"><p>See also INCOMPATIBLE OPTIONS below.</p></div>
1152 </dd>
1153 <dt class="hdlist1">
1154 --allow-empty-message
1155 </dt>
1156 <dd>
1158 No-op. Rebasing commits with an empty message used to fail
1159 and this option would override that behavior, allowing commits
1160 with empty messages to be rebased. Now commits with an empty
1161 message do not cause rebasing to halt.
1162 </p>
1163 <div class="paragraph"><p>See also INCOMPATIBLE OPTIONS below.</p></div>
1164 </dd>
1165 <dt class="hdlist1">
1167 </dt>
1168 <dt class="hdlist1">
1169 --merge
1170 </dt>
1171 <dd>
1173 Using merging strategies to rebase (default).
1174 </p>
1175 <div class="paragraph"><p>Note that a rebase merge works by replaying each commit from the working
1176 branch on top of the <code>&lt;upstream&gt;</code> branch. Because of this, when a merge
1177 conflict happens, the side reported as <em>ours</em> is the so-far rebased
1178 series, starting with <code>&lt;upstream&gt;</code>, and <em>theirs</em> is the working branch.
1179 In other words, the sides are swapped.</p></div>
1180 <div class="paragraph"><p>See also INCOMPATIBLE OPTIONS below.</p></div>
1181 </dd>
1182 <dt class="hdlist1">
1183 -s &lt;strategy&gt;
1184 </dt>
1185 <dt class="hdlist1">
1186 --strategy=&lt;strategy&gt;
1187 </dt>
1188 <dd>
1190 Use the given merge strategy, instead of the default <code>ort</code>.
1191 This implies <code>--merge</code>.
1192 </p>
1193 <div class="paragraph"><p>Because <code>git rebase</code> replays each commit from the working branch
1194 on top of the <code>&lt;upstream&gt;</code> branch using the given strategy, using
1195 the <code>ours</code> strategy simply empties all patches from the <code>&lt;branch&gt;</code>,
1196 which makes little sense.</p></div>
1197 <div class="paragraph"><p>See also INCOMPATIBLE OPTIONS below.</p></div>
1198 </dd>
1199 <dt class="hdlist1">
1200 -X &lt;strategy-option&gt;
1201 </dt>
1202 <dt class="hdlist1">
1203 --strategy-option=&lt;strategy-option&gt;
1204 </dt>
1205 <dd>
1207 Pass the &lt;strategy-option&gt; through to the merge strategy.
1208 This implies <code>--merge</code> and, if no strategy has been
1209 specified, <code>-s ort</code>. Note the reversal of <em>ours</em> and
1210 <em>theirs</em> as noted above for the <code>-m</code> option.
1211 </p>
1212 <div class="paragraph"><p>See also INCOMPATIBLE OPTIONS below.</p></div>
1213 </dd>
1214 <dt class="hdlist1">
1215 --rerere-autoupdate
1216 </dt>
1217 <dt class="hdlist1">
1218 --no-rerere-autoupdate
1219 </dt>
1220 <dd>
1222 After the rerere mechanism reuses a recorded resolution on
1223 the current conflict to update the files in the working
1224 tree, allow it to also update the index with the result of
1225 resolution. <code>--no-rerere-autoupdate</code> is a good way to
1226 double-check what <code>rerere</code> did and catch potential
1227 mismerges, before committing the result to the index with a
1228 separate <code>git add</code>.
1229 </p>
1230 </dd>
1231 <dt class="hdlist1">
1232 -S[&lt;keyid&gt;]
1233 </dt>
1234 <dt class="hdlist1">
1235 --gpg-sign[=&lt;keyid&gt;]
1236 </dt>
1237 <dt class="hdlist1">
1238 --no-gpg-sign
1239 </dt>
1240 <dd>
1242 GPG-sign commits. The <code>keyid</code> argument is optional and
1243 defaults to the committer identity; if specified, it must be
1244 stuck to the option without a space. <code>--no-gpg-sign</code> is useful to
1245 countermand both <code>commit.gpgSign</code> configuration variable, and
1246 earlier <code>--gpg-sign</code>.
1247 </p>
1248 </dd>
1249 <dt class="hdlist1">
1251 </dt>
1252 <dt class="hdlist1">
1253 --quiet
1254 </dt>
1255 <dd>
1257 Be quiet. Implies <code>--no-stat</code>.
1258 </p>
1259 </dd>
1260 <dt class="hdlist1">
1262 </dt>
1263 <dt class="hdlist1">
1264 --verbose
1265 </dt>
1266 <dd>
1268 Be verbose. Implies <code>--stat</code>.
1269 </p>
1270 </dd>
1271 <dt class="hdlist1">
1272 --stat
1273 </dt>
1274 <dd>
1276 Show a diffstat of what changed upstream since the last rebase. The
1277 diffstat is also controlled by the configuration option rebase.stat.
1278 </p>
1279 </dd>
1280 <dt class="hdlist1">
1282 </dt>
1283 <dt class="hdlist1">
1284 --no-stat
1285 </dt>
1286 <dd>
1288 Do not show a diffstat as part of the rebase process.
1289 </p>
1290 </dd>
1291 <dt class="hdlist1">
1292 --no-verify
1293 </dt>
1294 <dd>
1296 This option bypasses the pre-rebase hook. See also <a href="githooks.html">githooks(5)</a>.
1297 </p>
1298 </dd>
1299 <dt class="hdlist1">
1300 --verify
1301 </dt>
1302 <dd>
1304 Allows the pre-rebase hook to run, which is the default. This option can
1305 be used to override <code>--no-verify</code>. See also <a href="githooks.html">githooks(5)</a>.
1306 </p>
1307 </dd>
1308 <dt class="hdlist1">
1309 -C&lt;n&gt;
1310 </dt>
1311 <dd>
1313 Ensure at least <code>&lt;n&gt;</code> lines of surrounding context match before
1314 and after each change. When fewer lines of surrounding
1315 context exist they all must match. By default no context is
1316 ever ignored. Implies <code>--apply</code>.
1317 </p>
1318 <div class="paragraph"><p>See also INCOMPATIBLE OPTIONS below.</p></div>
1319 </dd>
1320 <dt class="hdlist1">
1321 --no-ff
1322 </dt>
1323 <dt class="hdlist1">
1324 --force-rebase
1325 </dt>
1326 <dt class="hdlist1">
1328 </dt>
1329 <dd>
1331 Individually replay all rebased commits instead of fast-forwarding
1332 over the unchanged ones. This ensures that the entire history of
1333 the rebased branch is composed of new commits.
1334 </p>
1335 <div class="paragraph"><p>You may find this helpful after reverting a topic branch merge, as this option
1336 recreates the topic branch with fresh commits so it can be remerged
1337 successfully without needing to "revert the reversion" (see the
1338 <a href="howto/revert-a-faulty-merge.html">revert-a-faulty-merge How-To</a> for
1339 details).</p></div>
1340 </dd>
1341 <dt class="hdlist1">
1342 --fork-point
1343 </dt>
1344 <dt class="hdlist1">
1345 --no-fork-point
1346 </dt>
1347 <dd>
1349 Use reflog to find a better common ancestor between <code>&lt;upstream&gt;</code>
1350 and <code>&lt;branch&gt;</code> when calculating which commits have been
1351 introduced by <code>&lt;branch&gt;</code>.
1352 </p>
1353 <div class="paragraph"><p>When <code>--fork-point</code> is active, <em>fork_point</em> will be used instead of
1354 <code>&lt;upstream&gt;</code> to calculate the set of commits to rebase, where
1355 <em>fork_point</em> is the result of <code>git merge-base --fork-point &lt;upstream&gt;
1356 &lt;branch&gt;</code> command (see <a href="git-merge-base.html">git-merge-base(1)</a>). If <em>fork_point</em>
1357 ends up being empty, the <code>&lt;upstream&gt;</code> will be used as a fallback.</p></div>
1358 <div class="paragraph"><p>If <code>&lt;upstream&gt;</code> or <code>--keep-base</code> is given on the command line, then
1359 the default is <code>--no-fork-point</code>, otherwise the default is
1360 <code>--fork-point</code>. See also <code>rebase.forkpoint</code> in <a href="git-config.html">git-config(1)</a>.</p></div>
1361 <div class="paragraph"><p>If your branch was based on <code>&lt;upstream&gt;</code> but <code>&lt;upstream&gt;</code> was rewound and
1362 your branch contains commits which were dropped, this option can be used
1363 with <code>--keep-base</code> in order to drop those commits from your branch.</p></div>
1364 <div class="paragraph"><p>See also INCOMPATIBLE OPTIONS below.</p></div>
1365 </dd>
1366 <dt class="hdlist1">
1367 --ignore-whitespace
1368 </dt>
1369 <dd>
1371 Ignore whitespace differences when trying to reconcile
1372 differences. Currently, each backend implements an approximation of
1373 this behavior:
1374 </p>
1375 <div class="dlist"><dl>
1376 <dt class="hdlist1">
1377 apply backend
1378 </dt>
1379 <dd>
1381 When applying a patch, ignore changes in whitespace in context
1382 lines. Unfortunately, this means that if the "old" lines being
1383 replaced by the patch differ only in whitespace from the existing
1384 file, you will get a merge conflict instead of a successful patch
1385 application.
1386 </p>
1387 </dd>
1388 <dt class="hdlist1">
1389 merge backend
1390 </dt>
1391 <dd>
1393 Treat lines with only whitespace changes as unchanged when merging.
1394 Unfortunately, this means that any patch hunks that were intended
1395 to modify whitespace and nothing else will be dropped, even if the
1396 other side had no changes that conflicted.
1397 </p>
1398 </dd>
1399 </dl></div>
1400 </dd>
1401 <dt class="hdlist1">
1402 --whitespace=&lt;option&gt;
1403 </dt>
1404 <dd>
1406 This flag is passed to the <code>git apply</code> program
1407 (see <a href="git-apply.html">git-apply(1)</a>) that applies the patch.
1408 Implies <code>--apply</code>.
1409 </p>
1410 <div class="paragraph"><p>See also INCOMPATIBLE OPTIONS below.</p></div>
1411 </dd>
1412 <dt class="hdlist1">
1413 --committer-date-is-author-date
1414 </dt>
1415 <dd>
1417 Instead of using the current time as the committer date, use
1418 the author date of the commit being rebased as the committer
1419 date. This option implies <code>--force-rebase</code>.
1420 </p>
1421 </dd>
1422 <dt class="hdlist1">
1423 --ignore-date
1424 </dt>
1425 <dt class="hdlist1">
1426 --reset-author-date
1427 </dt>
1428 <dd>
1430 Instead of using the author date of the original commit, use
1431 the current time as the author date of the rebased commit. This
1432 option implies <code>--force-rebase</code>.
1433 </p>
1434 <div class="paragraph"><p>See also INCOMPATIBLE OPTIONS below.</p></div>
1435 </dd>
1436 <dt class="hdlist1">
1437 --signoff
1438 </dt>
1439 <dd>
1441 Add a <code>Signed-off-by</code> trailer to all the rebased commits. Note
1442 that if <code>--interactive</code> is given then only commits marked to be
1443 picked, edited or reworded will have the trailer added.
1444 </p>
1445 <div class="paragraph"><p>See also INCOMPATIBLE OPTIONS below.</p></div>
1446 </dd>
1447 <dt class="hdlist1">
1449 </dt>
1450 <dt class="hdlist1">
1451 --interactive
1452 </dt>
1453 <dd>
1455 Make a list of the commits which are about to be rebased. Let the
1456 user edit that list before rebasing. This mode can also be used to
1457 split commits (see SPLITTING COMMITS below).
1458 </p>
1459 <div class="paragraph"><p>The commit list format can be changed by setting the configuration option
1460 rebase.instructionFormat. A customized instruction format will automatically
1461 have the long commit hash prepended to the format.</p></div>
1462 <div class="paragraph"><p>See also INCOMPATIBLE OPTIONS below.</p></div>
1463 </dd>
1464 <dt class="hdlist1">
1466 </dt>
1467 <dt class="hdlist1">
1468 --rebase-merges[=(rebase-cousins|no-rebase-cousins)]
1469 </dt>
1470 <dt class="hdlist1">
1471 --no-rebase-merges
1472 </dt>
1473 <dd>
1475 By default, a rebase will simply drop merge commits from the todo
1476 list, and put the rebased commits into a single, linear branch.
1477 With <code>--rebase-merges</code>, the rebase will instead try to preserve
1478 the branching structure within the commits that are to be rebased,
1479 by recreating the merge commits. Any resolved merge conflicts or
1480 manual amendments in these merge commits will have to be
1481 resolved/re-applied manually. <code>--no-rebase-merges</code> can be used to
1482 countermand both the <code>rebase.rebaseMerges</code> config option and a previous
1483 <code>--rebase-merges</code>.
1484 </p>
1485 <div class="paragraph"><p>When rebasing merges, there are two modes: <code>rebase-cousins</code> and
1486 <code>no-rebase-cousins</code>. If the mode is not specified, it defaults to
1487 <code>no-rebase-cousins</code>. In <code>no-rebase-cousins</code> mode, commits which do not have
1488 <code>&lt;upstream&gt;</code> as direct ancestor will keep their original branch point, i.e.
1489 commits that would be excluded by <a href="git-log.html">git-log(1)</a>'s <code>--ancestry-path</code>
1490 option will keep their original ancestry by default. In <code>rebase-cousins</code> mode,
1491 such commits are instead rebased onto <code>&lt;upstream&gt;</code> (or <code>&lt;onto&gt;</code>, if
1492 specified).</p></div>
1493 <div class="paragraph"><p>It is currently only possible to recreate the merge commits using the
1494 <code>ort</code> merge strategy; different merge strategies can be used only via
1495 explicit <code>exec git merge -s &lt;strategy&gt; [...]</code> commands.</p></div>
1496 <div class="paragraph"><p>See also REBASING MERGES and INCOMPATIBLE OPTIONS below.</p></div>
1497 </dd>
1498 <dt class="hdlist1">
1499 -x &lt;cmd&gt;
1500 </dt>
1501 <dt class="hdlist1">
1502 --exec &lt;cmd&gt;
1503 </dt>
1504 <dd>
1506 Append "exec &lt;cmd&gt;" after each line creating a commit in the
1507 final history. <code>&lt;cmd&gt;</code> will be interpreted as one or more shell
1508 commands. Any command that fails will interrupt the rebase,
1509 with exit code 1.
1510 </p>
1511 <div class="paragraph"><p>You may execute several commands by either using one instance of <code>--exec</code>
1512 with several commands:</p></div>
1513 <div class="literalblock">
1514 <div class="content">
1515 <pre><code>git rebase -i --exec "cmd1 &amp;&amp; cmd2 &amp;&amp; ..."</code></pre>
1516 </div></div>
1517 <div class="paragraph"><p>or by giving more than one <code>--exec</code>:</p></div>
1518 <div class="literalblock">
1519 <div class="content">
1520 <pre><code>git rebase -i --exec "cmd1" --exec "cmd2" --exec ...</code></pre>
1521 </div></div>
1522 <div class="paragraph"><p>If <code>--autosquash</code> is used, <code>exec</code> lines will not be appended for
1523 the intermediate commits, and will only appear at the end of each
1524 squash/fixup series.</p></div>
1525 <div class="paragraph"><p>This uses the <code>--interactive</code> machinery internally, but it can be run
1526 without an explicit <code>--interactive</code>.</p></div>
1527 <div class="paragraph"><p>See also INCOMPATIBLE OPTIONS below.</p></div>
1528 </dd>
1529 <dt class="hdlist1">
1530 --root
1531 </dt>
1532 <dd>
1534 Rebase all commits reachable from <code>&lt;branch&gt;</code>, instead of
1535 limiting them with an <code>&lt;upstream&gt;</code>. This allows you to rebase
1536 the root commit(s) on a branch.
1537 </p>
1538 <div class="paragraph"><p>See also INCOMPATIBLE OPTIONS below.</p></div>
1539 </dd>
1540 <dt class="hdlist1">
1541 --autosquash
1542 </dt>
1543 <dt class="hdlist1">
1544 --no-autosquash
1545 </dt>
1546 <dd>
1548 When the commit log message begins with "squash! &#8230;" or "fixup! &#8230;"
1549 or "amend! &#8230;", and there is already a commit in the todo list that
1550 matches the same <code>...</code>, automatically modify the todo list of
1551 <code>rebase -i</code>, so that the commit marked for squashing comes right after
1552 the commit to be modified, and change the action of the moved commit
1553 from <code>pick</code> to <code>squash</code> or <code>fixup</code> or <code>fixup -C</code> respectively. A commit
1554 matches the <code>...</code> if the commit subject matches, or if the <code>...</code> refers
1555 to the commit&#8217;s hash. As a fall-back, partial matches of the commit
1556 subject work, too. The recommended way to create fixup/amend/squash
1557 commits is by using the <code>--fixup</code>, <code>--fixup=amend:</code> or <code>--fixup=reword:</code>
1558 and <code>--squash</code> options respectively of <a href="git-commit.html">git-commit(1)</a>.
1559 </p>
1560 <div class="paragraph"><p>If the <code>--autosquash</code> option is enabled by default using the
1561 configuration variable <code>rebase.autoSquash</code>, this option can be
1562 used to override and disable this setting.</p></div>
1563 <div class="paragraph"><p>See also INCOMPATIBLE OPTIONS below.</p></div>
1564 </dd>
1565 <dt class="hdlist1">
1566 --autostash
1567 </dt>
1568 <dt class="hdlist1">
1569 --no-autostash
1570 </dt>
1571 <dd>
1573 Automatically create a temporary stash entry before the operation
1574 begins, and apply it after the operation ends. This means
1575 that you can run rebase on a dirty worktree. However, use
1576 with care: the final stash application after a successful
1577 rebase might result in non-trivial conflicts.
1578 </p>
1579 </dd>
1580 <dt class="hdlist1">
1581 --reschedule-failed-exec
1582 </dt>
1583 <dt class="hdlist1">
1584 --no-reschedule-failed-exec
1585 </dt>
1586 <dd>
1588 Automatically reschedule <code>exec</code> commands that failed. This only makes
1589 sense in interactive mode (or when an <code>--exec</code> option was provided).
1590 </p>
1591 <div class="paragraph"><p>Even though this option applies once a rebase is started, it&#8217;s set for
1592 the whole rebase at the start based on either the
1593 <code>rebase.rescheduleFailedExec</code> configuration (see <a href="git-config.html">git-config(1)</a>
1594 or "CONFIGURATION" below) or whether this option is
1595 provided. Otherwise an explicit <code>--no-reschedule-failed-exec</code> at the
1596 start would be overridden by the presence of
1597 <code>rebase.rescheduleFailedExec=true</code> configuration.</p></div>
1598 </dd>
1599 <dt class="hdlist1">
1600 --update-refs
1601 </dt>
1602 <dt class="hdlist1">
1603 --no-update-refs
1604 </dt>
1605 <dd>
1607 Automatically force-update any branches that point to commits that
1608 are being rebased. Any branches that are checked out in a worktree
1609 are not updated in this way.
1610 </p>
1611 <div class="paragraph"><p>If the configuration variable <code>rebase.updateRefs</code> is set, then this option
1612 can be used to override and disable this setting.</p></div>
1613 <div class="paragraph"><p>See also INCOMPATIBLE OPTIONS below.</p></div>
1614 </dd>
1615 </dl></div>
1616 </div>
1617 </div>
1618 <div class="sect1">
1619 <h2 id="_incompatible_options">INCOMPATIBLE OPTIONS</h2>
1620 <div class="sectionbody">
1621 <div class="paragraph"><p>The following options:</p></div>
1622 <div class="ulist"><ul>
1623 <li>
1625 --apply
1626 </p>
1627 </li>
1628 <li>
1630 --whitespace
1631 </p>
1632 </li>
1633 <li>
1636 </p>
1637 </li>
1638 </ul></div>
1639 <div class="paragraph"><p>are incompatible with the following options:</p></div>
1640 <div class="ulist"><ul>
1641 <li>
1643 --merge
1644 </p>
1645 </li>
1646 <li>
1648 --strategy
1649 </p>
1650 </li>
1651 <li>
1653 --strategy-option
1654 </p>
1655 </li>
1656 <li>
1658 --autosquash
1659 </p>
1660 </li>
1661 <li>
1663 --rebase-merges
1664 </p>
1665 </li>
1666 <li>
1668 --interactive
1669 </p>
1670 </li>
1671 <li>
1673 --exec
1674 </p>
1675 </li>
1676 <li>
1678 --no-keep-empty
1679 </p>
1680 </li>
1681 <li>
1683 --empty=
1684 </p>
1685 </li>
1686 <li>
1688 --[no-]reapply-cherry-picks when used without --keep-base
1689 </p>
1690 </li>
1691 <li>
1693 --update-refs
1694 </p>
1695 </li>
1696 <li>
1698 --root when used without --onto
1699 </p>
1700 </li>
1701 </ul></div>
1702 <div class="paragraph"><p>In addition, the following pairs of options are incompatible:</p></div>
1703 <div class="ulist"><ul>
1704 <li>
1706 --keep-base and --onto
1707 </p>
1708 </li>
1709 <li>
1711 --keep-base and --root
1712 </p>
1713 </li>
1714 <li>
1716 --fork-point and --root
1717 </p>
1718 </li>
1719 </ul></div>
1720 </div>
1721 </div>
1722 <div class="sect1">
1723 <h2 id="_behavioral_differences">BEHAVIORAL DIFFERENCES</h2>
1724 <div class="sectionbody">
1725 <div class="paragraph"><p><code>git rebase</code> has two primary backends: <em>apply</em> and <em>merge</em>. (The <em>apply</em>
1726 backend used to be known as the <em>am</em> backend, but the name led to
1727 confusion as it looks like a verb instead of a noun. Also, the <em>merge</em>
1728 backend used to be known as the interactive backend, but it is now
1729 used for non-interactive cases as well. Both were renamed based on
1730 lower-level functionality that underpinned each.) There are some
1731 subtle differences in how these two backends behave:</p></div>
1732 <div class="sect2">
1733 <h3 id="_empty_commits">Empty commits</h3>
1734 <div class="paragraph"><p>The <em>apply</em> backend unfortunately drops intentionally empty commits, i.e.
1735 commits that started empty, though these are rare in practice. It
1736 also drops commits that become empty and has no option for controlling
1737 this behavior.</p></div>
1738 <div class="paragraph"><p>The <em>merge</em> backend keeps intentionally empty commits by default (though
1739 with <code>-i</code> they are marked as empty in the todo list editor, or they can
1740 be dropped automatically with <code>--no-keep-empty</code>).</p></div>
1741 <div class="paragraph"><p>Similar to the apply backend, by default the merge backend drops
1742 commits that become empty unless <code>-i</code>/<code>--interactive</code> is specified (in
1743 which case it stops and asks the user what to do). The merge backend
1744 also has an <code>--empty={drop,keep,ask}</code> option for changing the behavior
1745 of handling commits that become empty.</p></div>
1746 </div>
1747 <div class="sect2">
1748 <h3 id="_directory_rename_detection">Directory rename detection</h3>
1749 <div class="paragraph"><p>Due to the lack of accurate tree information (arising from
1750 constructing fake ancestors with the limited information available in
1751 patches), directory rename detection is disabled in the <em>apply</em> backend.
1752 Disabled directory rename detection means that if one side of history
1753 renames a directory and the other adds new files to the old directory,
1754 then the new files will be left behind in the old directory without
1755 any warning at the time of rebasing that you may want to move these
1756 files into the new directory.</p></div>
1757 <div class="paragraph"><p>Directory rename detection works with the <em>merge</em> backend to provide you
1758 warnings in such cases.</p></div>
1759 </div>
1760 <div class="sect2">
1761 <h3 id="_context">Context</h3>
1762 <div class="paragraph"><p>The <em>apply</em> backend works by creating a sequence of patches (by calling
1763 <code>format-patch</code> internally), and then applying the patches in sequence
1764 (calling <code>am</code> internally). Patches are composed of multiple hunks,
1765 each with line numbers, a context region, and the actual changes. The
1766 line numbers have to be taken with some fuzz, since the other side
1767 will likely have inserted or deleted lines earlier in the file. The
1768 context region is meant to help find how to adjust the line numbers in
1769 order to apply the changes to the right lines. However, if multiple
1770 areas of the code have the same surrounding lines of context, the
1771 wrong one can be picked. There are real-world cases where this has
1772 caused commits to be reapplied incorrectly with no conflicts reported.
1773 Setting <code>diff.context</code> to a larger value may prevent such types of
1774 problems, but increases the chance of spurious conflicts (since it
1775 will require more lines of matching context to apply).</p></div>
1776 <div class="paragraph"><p>The <em>merge</em> backend works with a full copy of each relevant file,
1777 insulating it from these types of problems.</p></div>
1778 </div>
1779 <div class="sect2">
1780 <h3 id="_labelling_of_conflicts_markers">Labelling of conflicts markers</h3>
1781 <div class="paragraph"><p>When there are content conflicts, the merge machinery tries to
1782 annotate each side&#8217;s conflict markers with the commits where the
1783 content came from. Since the <em>apply</em> backend drops the original
1784 information about the rebased commits and their parents (and instead
1785 generates new fake commits based off limited information in the
1786 generated patches), those commits cannot be identified; instead it has
1787 to fall back to a commit summary. Also, when <code>merge.conflictStyle</code> is
1788 set to <code>diff3</code> or <code>zdiff3</code>, the <em>apply</em> backend will use "constructed merge
1789 base" to label the content from the merge base, and thus provide no
1790 information about the merge base commit whatsoever.</p></div>
1791 <div class="paragraph"><p>The <em>merge</em> backend works with the full commits on both sides of history
1792 and thus has no such limitations.</p></div>
1793 </div>
1794 <div class="sect2">
1795 <h3 id="_hooks">Hooks</h3>
1796 <div class="paragraph"><p>The <em>apply</em> backend has not traditionally called the post-commit hook,
1797 while the <em>merge</em> backend has. Both have called the post-checkout hook,
1798 though the <em>merge</em> backend has squelched its output. Further, both
1799 backends only call the post-checkout hook with the starting point
1800 commit of the rebase, not the intermediate commits nor the final
1801 commit. In each case, the calling of these hooks was by accident of
1802 implementation rather than by design (both backends were originally
1803 implemented as shell scripts and happened to invoke other commands
1804 like <code>git checkout</code> or <code>git commit</code> that would call the hooks). Both
1805 backends should have the same behavior, though it is not entirely
1806 clear which, if any, is correct. We will likely make rebase stop
1807 calling either of these hooks in the future.</p></div>
1808 </div>
1809 <div class="sect2">
1810 <h3 id="_interruptability">Interruptability</h3>
1811 <div class="paragraph"><p>The <em>apply</em> backend has safety problems with an ill-timed interrupt; if
1812 the user presses Ctrl-C at the wrong time to try to abort the rebase,
1813 the rebase can enter a state where it cannot be aborted with a
1814 subsequent <code>git rebase --abort</code>. The <em>merge</em> backend does not appear to
1815 suffer from the same shortcoming. (See
1816 <a href="https://lore.kernel.org/git/20200207132152.GC2868@szeder.dev/">https://lore.kernel.org/git/20200207132152.GC2868@szeder.dev/</a> for
1817 details.)</p></div>
1818 </div>
1819 <div class="sect2">
1820 <h3 id="_commit_rewording">Commit Rewording</h3>
1821 <div class="paragraph"><p>When a conflict occurs while rebasing, rebase stops and asks the user
1822 to resolve. Since the user may need to make notable changes while
1823 resolving conflicts, after conflicts are resolved and the user has run
1824 <code>git rebase --continue</code>, the rebase should open an editor and ask the
1825 user to update the commit message. The <em>merge</em> backend does this, while
1826 the <em>apply</em> backend blindly applies the original commit message.</p></div>
1827 </div>
1828 <div class="sect2">
1829 <h3 id="_miscellaneous_differences">Miscellaneous differences</h3>
1830 <div class="paragraph"><p>There are a few more behavioral differences that most folks would
1831 probably consider inconsequential but which are mentioned for
1832 completeness:</p></div>
1833 <div class="ulist"><ul>
1834 <li>
1836 Reflog: The two backends will use different wording when describing
1837 the changes made in the reflog, though both will make use of the
1838 word "rebase".
1839 </p>
1840 </li>
1841 <li>
1843 Progress, informational, and error messages: The two backends
1844 provide slightly different progress and informational messages.
1845 Also, the apply backend writes error messages (such as "Your files
1846 would be overwritten&#8230;") to stdout, while the merge backend writes
1847 them to stderr.
1848 </p>
1849 </li>
1850 <li>
1852 State directories: The two backends keep their state in different
1853 directories under <code>.git/</code>
1854 </p>
1855 </li>
1856 </ul></div>
1857 </div>
1858 </div>
1859 </div>
1860 <div class="sect1">
1861 <h2 id="_merge_strategies">MERGE STRATEGIES</h2>
1862 <div class="sectionbody">
1863 <div class="paragraph"><p>The merge mechanism (<code>git merge</code> and <code>git pull</code> commands) allows the
1864 backend <em>merge strategies</em> to be chosen with <code>-s</code> option. Some strategies
1865 can also take their own options, which can be passed by giving <code>-X&lt;option&gt;</code>
1866 arguments to <code>git merge</code> and/or <code>git pull</code>.</p></div>
1867 <div class="dlist"><dl>
1868 <dt class="hdlist1">
1870 </dt>
1871 <dd>
1873 This is the default merge strategy when pulling or merging one
1874 branch. This strategy can only resolve two heads using a
1875 3-way merge algorithm. When there is more than one common
1876 ancestor that can be used for 3-way merge, it creates a merged
1877 tree of the common ancestors and uses that as the reference
1878 tree for the 3-way merge. This has been reported to result in
1879 fewer merge conflicts without causing mismerges by tests done
1880 on actual merge commits taken from Linux 2.6 kernel
1881 development history. Additionally this strategy can detect
1882 and handle merges involving renames. It does not make use of
1883 detected copies. The name for this algorithm is an acronym
1884 ("Ostensibly Recursive&#8217;s Twin") and came from the fact that it
1885 was written as a replacement for the previous default
1886 algorithm, <code>recursive</code>.
1887 </p>
1888 <div class="paragraph"><p>The <em>ort</em> strategy can take the following options:</p></div>
1889 <div class="dlist"><dl>
1890 <dt class="hdlist1">
1891 ours
1892 </dt>
1893 <dd>
1895 This option forces conflicting hunks to be auto-resolved cleanly by
1896 favoring <em>our</em> version. Changes from the other tree that do not
1897 conflict with our side are reflected in the merge result.
1898 For a binary file, the entire contents are taken from our side.
1899 </p>
1900 <div class="paragraph"><p>This should not be confused with the <em>ours</em> merge strategy, which does not
1901 even look at what the other tree contains at all. It discards everything
1902 the other tree did, declaring <em>our</em> history contains all that happened in it.</p></div>
1903 </dd>
1904 <dt class="hdlist1">
1905 theirs
1906 </dt>
1907 <dd>
1909 This is the opposite of <em>ours</em>; note that, unlike <em>ours</em>, there is
1910 no <em>theirs</em> merge strategy to confuse this merge option with.
1911 </p>
1912 </dd>
1913 <dt class="hdlist1">
1914 ignore-space-change
1915 </dt>
1916 <dt class="hdlist1">
1917 ignore-all-space
1918 </dt>
1919 <dt class="hdlist1">
1920 ignore-space-at-eol
1921 </dt>
1922 <dt class="hdlist1">
1923 ignore-cr-at-eol
1924 </dt>
1925 <dd>
1927 Treats lines with the indicated type of whitespace change as
1928 unchanged for the sake of a three-way merge. Whitespace
1929 changes mixed with other changes to a line are not ignored.
1930 See also <a href="git-diff.html">git-diff(1)</a> <code>-b</code>, <code>-w</code>,
1931 <code>--ignore-space-at-eol</code>, and <code>--ignore-cr-at-eol</code>.
1932 </p>
1933 <div class="ulist"><ul>
1934 <li>
1936 If <em>their</em> version only introduces whitespace changes to a line,
1937 <em>our</em> version is used;
1938 </p>
1939 </li>
1940 <li>
1942 If <em>our</em> version introduces whitespace changes but <em>their</em>
1943 version includes a substantial change, <em>their</em> version is used;
1944 </p>
1945 </li>
1946 <li>
1948 Otherwise, the merge proceeds in the usual way.
1949 </p>
1950 </li>
1951 </ul></div>
1952 </dd>
1953 <dt class="hdlist1">
1954 renormalize
1955 </dt>
1956 <dd>
1958 This runs a virtual check-out and check-in of all three stages
1959 of a file when resolving a three-way merge. This option is
1960 meant to be used when merging branches with different clean
1961 filters or end-of-line normalization rules. See "Merging
1962 branches with differing checkin/checkout attributes" in
1963 <a href="gitattributes.html">gitattributes(5)</a> for details.
1964 </p>
1965 </dd>
1966 <dt class="hdlist1">
1967 no-renormalize
1968 </dt>
1969 <dd>
1971 Disables the <code>renormalize</code> option. This overrides the
1972 <code>merge.renormalize</code> configuration variable.
1973 </p>
1974 </dd>
1975 <dt class="hdlist1">
1976 find-renames[=&lt;n&gt;]
1977 </dt>
1978 <dd>
1980 Turn on rename detection, optionally setting the similarity
1981 threshold. This is the default. This overrides the
1982 <em>merge.renames</em> configuration variable.
1983 See also <a href="git-diff.html">git-diff(1)</a> <code>--find-renames</code>.
1984 </p>
1985 </dd>
1986 <dt class="hdlist1">
1987 rename-threshold=&lt;n&gt;
1988 </dt>
1989 <dd>
1991 Deprecated synonym for <code>find-renames=&lt;n&gt;</code>.
1992 </p>
1993 </dd>
1994 <dt class="hdlist1">
1995 subtree[=&lt;path&gt;]
1996 </dt>
1997 <dd>
1999 This option is a more advanced form of <em>subtree</em> strategy, where
2000 the strategy makes a guess on how two trees must be shifted to
2001 match with each other when merging. Instead, the specified path
2002 is prefixed (or stripped from the beginning) to make the shape of
2003 two trees to match.
2004 </p>
2005 </dd>
2006 </dl></div>
2007 </dd>
2008 <dt class="hdlist1">
2009 recursive
2010 </dt>
2011 <dd>
2013 This can only resolve two heads using a 3-way merge
2014 algorithm. When there is more than one common
2015 ancestor that can be used for 3-way merge, it creates a
2016 merged tree of the common ancestors and uses that as
2017 the reference tree for the 3-way merge. This has been
2018 reported to result in fewer merge conflicts without
2019 causing mismerges by tests done on actual merge commits
2020 taken from Linux 2.6 kernel development history.
2021 Additionally this can detect and handle merges involving
2022 renames. It does not make use of detected copies. This was
2023 the default strategy for resolving two heads from Git v0.99.9k
2024 until v2.33.0.
2025 </p>
2026 <div class="paragraph"><p>The <em>recursive</em> strategy takes the same options as <em>ort</em>. However,
2027 there are three additional options that <em>ort</em> ignores (not documented
2028 above) that are potentially useful with the <em>recursive</em> strategy:</p></div>
2029 <div class="dlist"><dl>
2030 <dt class="hdlist1">
2031 patience
2032 </dt>
2033 <dd>
2035 Deprecated synonym for <code>diff-algorithm=patience</code>.
2036 </p>
2037 </dd>
2038 <dt class="hdlist1">
2039 diff-algorithm=[patience|minimal|histogram|myers]
2040 </dt>
2041 <dd>
2043 Use a different diff algorithm while merging, which can help
2044 avoid mismerges that occur due to unimportant matching lines
2045 (such as braces from distinct functions). See also
2046 <a href="git-diff.html">git-diff(1)</a> <code>--diff-algorithm</code>. Note that <code>ort</code>
2047 specifically uses <code>diff-algorithm=histogram</code>, while <code>recursive</code>
2048 defaults to the <code>diff.algorithm</code> config setting.
2049 </p>
2050 </dd>
2051 <dt class="hdlist1">
2052 no-renames
2053 </dt>
2054 <dd>
2056 Turn off rename detection. This overrides the <code>merge.renames</code>
2057 configuration variable.
2058 See also <a href="git-diff.html">git-diff(1)</a> <code>--no-renames</code>.
2059 </p>
2060 </dd>
2061 </dl></div>
2062 </dd>
2063 <dt class="hdlist1">
2064 resolve
2065 </dt>
2066 <dd>
2068 This can only resolve two heads (i.e. the current branch
2069 and another branch you pulled from) using a 3-way merge
2070 algorithm. It tries to carefully detect criss-cross
2071 merge ambiguities. It does not handle renames.
2072 </p>
2073 </dd>
2074 <dt class="hdlist1">
2075 octopus
2076 </dt>
2077 <dd>
2079 This resolves cases with more than two heads, but refuses to do
2080 a complex merge that needs manual resolution. It is
2081 primarily meant to be used for bundling topic branch
2082 heads together. This is the default merge strategy when
2083 pulling or merging more than one branch.
2084 </p>
2085 </dd>
2086 <dt class="hdlist1">
2087 ours
2088 </dt>
2089 <dd>
2091 This resolves any number of heads, but the resulting tree of the
2092 merge is always that of the current branch head, effectively
2093 ignoring all changes from all other branches. It is meant to
2094 be used to supersede old development history of side
2095 branches. Note that this is different from the -Xours option to
2096 the <em>recursive</em> merge strategy.
2097 </p>
2098 </dd>
2099 <dt class="hdlist1">
2100 subtree
2101 </dt>
2102 <dd>
2104 This is a modified <code>ort</code> strategy. When merging trees A and
2105 B, if B corresponds to a subtree of A, B is first adjusted to
2106 match the tree structure of A, instead of reading the trees at
2107 the same level. This adjustment is also done to the common
2108 ancestor tree.
2109 </p>
2110 </dd>
2111 </dl></div>
2112 <div class="paragraph"><p>With the strategies that use 3-way merge (including the default, <em>ort</em>),
2113 if a change is made on both branches, but later reverted on one of the
2114 branches, that change will be present in the merged result; some people find
2115 this behavior confusing. It occurs because only the heads and the merge base
2116 are considered when performing a merge, not the individual commits. The merge
2117 algorithm therefore considers the reverted change as no change at all, and
2118 substitutes the changed version instead.</p></div>
2119 </div>
2120 </div>
2121 <div class="sect1">
2122 <h2 id="_notes">NOTES</h2>
2123 <div class="sectionbody">
2124 <div class="paragraph"><p>You should understand the implications of using <code>git rebase</code> on a
2125 repository that you share. See also RECOVERING FROM UPSTREAM REBASE
2126 below.</p></div>
2127 <div class="paragraph"><p>When the rebase is run, it will first execute a <code>pre-rebase</code> hook if one
2128 exists. You can use this hook to do sanity checks and reject the rebase
2129 if it isn&#8217;t appropriate. Please see the template <code>pre-rebase</code> hook script
2130 for an example.</p></div>
2131 <div class="paragraph"><p>Upon completion, <code>&lt;branch&gt;</code> will be the current branch.</p></div>
2132 </div>
2133 </div>
2134 <div class="sect1">
2135 <h2 id="_interactive_mode">INTERACTIVE MODE</h2>
2136 <div class="sectionbody">
2137 <div class="paragraph"><p>Rebasing interactively means that you have a chance to edit the commits
2138 which are rebased. You can reorder the commits, and you can
2139 remove them (weeding out bad or otherwise unwanted patches).</p></div>
2140 <div class="paragraph"><p>The interactive mode is meant for this type of workflow:</p></div>
2141 <div class="olist arabic"><ol class="arabic">
2142 <li>
2144 have a wonderful idea
2145 </p>
2146 </li>
2147 <li>
2149 hack on the code
2150 </p>
2151 </li>
2152 <li>
2154 prepare a series for submission
2155 </p>
2156 </li>
2157 <li>
2159 submit
2160 </p>
2161 </li>
2162 </ol></div>
2163 <div class="paragraph"><p>where point 2. consists of several instances of</p></div>
2164 <div class="paragraph"><p>a) regular use</p></div>
2165 <div class="olist arabic"><ol class="arabic">
2166 <li>
2168 finish something worthy of a commit
2169 </p>
2170 </li>
2171 <li>
2173 commit
2174 </p>
2175 </li>
2176 </ol></div>
2177 <div class="paragraph"><p>b) independent fixup</p></div>
2178 <div class="olist arabic"><ol class="arabic">
2179 <li>
2181 realize that something does not work
2182 </p>
2183 </li>
2184 <li>
2186 fix that
2187 </p>
2188 </li>
2189 <li>
2191 commit it
2192 </p>
2193 </li>
2194 </ol></div>
2195 <div class="paragraph"><p>Sometimes the thing fixed in b.2. cannot be amended to the not-quite
2196 perfect commit it fixes, because that commit is buried deeply in a
2197 patch series. That is exactly what interactive rebase is for: use it
2198 after plenty of "a"s and "b"s, by rearranging and editing
2199 commits, and squashing multiple commits into one.</p></div>
2200 <div class="paragraph"><p>Start it with the last commit you want to retain as-is:</p></div>
2201 <div class="literalblock">
2202 <div class="content">
2203 <pre><code>git rebase -i &lt;after-this-commit&gt;</code></pre>
2204 </div></div>
2205 <div class="paragraph"><p>An editor will be fired up with all the commits in your current branch
2206 (ignoring merge commits), which come after the given commit. You can
2207 reorder the commits in this list to your heart&#8217;s content, and you can
2208 remove them. The list looks more or less like this:</p></div>
2209 <div class="listingblock">
2210 <div class="content">
2211 <pre><code>pick deadbee The oneline of this commit
2212 pick fa1afe1 The oneline of the next commit
2213 ...</code></pre>
2214 </div></div>
2215 <div class="paragraph"><p>The oneline descriptions are purely for your pleasure; <em>git rebase</em> will
2216 not look at them but at the commit names ("deadbee" and "fa1afe1" in this
2217 example), so do not delete or edit the names.</p></div>
2218 <div class="paragraph"><p>By replacing the command "pick" with the command "edit", you can tell
2219 <code>git rebase</code> to stop after applying that commit, so that you can edit
2220 the files and/or the commit message, amend the commit, and continue
2221 rebasing.</p></div>
2222 <div class="paragraph"><p>To interrupt the rebase (just like an "edit" command would do, but without
2223 cherry-picking any commit first), use the "break" command.</p></div>
2224 <div class="paragraph"><p>If you just want to edit the commit message for a commit, replace the
2225 command "pick" with the command "reword".</p></div>
2226 <div class="paragraph"><p>To drop a commit, replace the command "pick" with "drop", or just
2227 delete the matching line.</p></div>
2228 <div class="paragraph"><p>If you want to fold two or more commits into one, replace the command
2229 "pick" for the second and subsequent commits with "squash" or "fixup".
2230 If the commits had different authors, the folded commit will be
2231 attributed to the author of the first commit. The suggested commit
2232 message for the folded commit is the concatenation of the first
2233 commit&#8217;s message with those identified by "squash" commands, omitting the
2234 messages of commits identified by "fixup" commands, unless "fixup -c"
2235 is used. In that case the suggested commit message is only the message
2236 of the "fixup -c" commit, and an editor is opened allowing you to edit
2237 the message. The contents (patch) of the "fixup -c" commit are still
2238 incorporated into the folded commit. If there is more than one "fixup -c"
2239 commit, the message from the final one is used. You can also use
2240 "fixup -C" to get the same behavior as "fixup -c" except without opening
2241 an editor.</p></div>
2242 <div class="paragraph"><p><code>git rebase</code> will stop when "pick" has been replaced with "edit" or
2243 when a command fails due to merge errors. When you are done editing
2244 and/or resolving conflicts you can continue with <code>git rebase --continue</code>.</p></div>
2245 <div class="paragraph"><p>For example, if you want to reorder the last 5 commits, such that what
2246 was <code>HEAD~4</code> becomes the new <code>HEAD</code>. To achieve that, you would call
2247 <code>git rebase</code> like this:</p></div>
2248 <div class="listingblock">
2249 <div class="content">
2250 <pre><code>$ git rebase -i HEAD~5</code></pre>
2251 </div></div>
2252 <div class="paragraph"><p>And move the first patch to the end of the list.</p></div>
2253 <div class="paragraph"><p>You might want to recreate merge commits, e.g. if you have a history
2254 like this:</p></div>
2255 <div class="listingblock">
2256 <div class="content">
2257 <pre><code> X
2259 A---M---B
2261 ---o---O---P---Q</code></pre>
2262 </div></div>
2263 <div class="paragraph"><p>Suppose you want to rebase the side branch starting at "A" to "Q". Make
2264 sure that the current <code>HEAD</code> is "B", and call</p></div>
2265 <div class="listingblock">
2266 <div class="content">
2267 <pre><code>$ git rebase -i -r --onto Q O</code></pre>
2268 </div></div>
2269 <div class="paragraph"><p>Reordering and editing commits usually creates untested intermediate
2270 steps. You may want to check that your history editing did not break
2271 anything by running a test, or at least recompiling at intermediate
2272 points in history by using the "exec" command (shortcut "x"). You may
2273 do so by creating a todo list like this one:</p></div>
2274 <div class="listingblock">
2275 <div class="content">
2276 <pre><code>pick deadbee Implement feature XXX
2277 fixup f1a5c00 Fix to feature XXX
2278 exec make
2279 pick c0ffeee The oneline of the next commit
2280 edit deadbab The oneline of the commit after
2281 exec cd subdir; make test
2282 ...</code></pre>
2283 </div></div>
2284 <div class="paragraph"><p>The interactive rebase will stop when a command fails (i.e. exits with
2285 non-0 status) to give you an opportunity to fix the problem. You can
2286 continue with <code>git rebase --continue</code>.</p></div>
2287 <div class="paragraph"><p>The "exec" command launches the command in a shell (the one specified
2288 in <code>$SHELL</code>, or the default shell if <code>$SHELL</code> is not set), so you can
2289 use shell features (like "cd", "&gt;", ";" &#8230;). The command is run from
2290 the root of the working tree.</p></div>
2291 <div class="listingblock">
2292 <div class="content">
2293 <pre><code>$ git rebase -i --exec "make test"</code></pre>
2294 </div></div>
2295 <div class="paragraph"><p>This command lets you check that intermediate commits are compilable.
2296 The todo list becomes like that:</p></div>
2297 <div class="listingblock">
2298 <div class="content">
2299 <pre><code>pick 5928aea one
2300 exec make test
2301 pick 04d0fda two
2302 exec make test
2303 pick ba46169 three
2304 exec make test
2305 pick f4593f9 four
2306 exec make test</code></pre>
2307 </div></div>
2308 </div>
2309 </div>
2310 <div class="sect1">
2311 <h2 id="_splitting_commits">SPLITTING COMMITS</h2>
2312 <div class="sectionbody">
2313 <div class="paragraph"><p>In interactive mode, you can mark commits with the action "edit". However,
2314 this does not necessarily mean that <code>git rebase</code> expects the result of this
2315 edit to be exactly one commit. Indeed, you can undo the commit, or you can
2316 add other commits. This can be used to split a commit into two:</p></div>
2317 <div class="ulist"><ul>
2318 <li>
2320 Start an interactive rebase with <code>git rebase -i &lt;commit&gt;^</code>, where
2321 <code>&lt;commit&gt;</code> is the commit you want to split. In fact, any commit range
2322 will do, as long as it contains that commit.
2323 </p>
2324 </li>
2325 <li>
2327 Mark the commit you want to split with the action "edit".
2328 </p>
2329 </li>
2330 <li>
2332 When it comes to editing that commit, execute <code>git reset HEAD^</code>. The
2333 effect is that the <code>HEAD</code> is rewound by one, and the index follows suit.
2334 However, the working tree stays the same.
2335 </p>
2336 </li>
2337 <li>
2339 Now add the changes to the index that you want to have in the first
2340 commit. You can use <code>git add</code> (possibly interactively) or
2341 <code>git gui</code> (or both) to do that.
2342 </p>
2343 </li>
2344 <li>
2346 Commit the now-current index with whatever commit message is appropriate
2347 now.
2348 </p>
2349 </li>
2350 <li>
2352 Repeat the last two steps until your working tree is clean.
2353 </p>
2354 </li>
2355 <li>
2357 Continue the rebase with <code>git rebase --continue</code>.
2358 </p>
2359 </li>
2360 </ul></div>
2361 <div class="paragraph"><p>If you are not absolutely sure that the intermediate revisions are
2362 consistent (they compile, pass the testsuite, etc.) you should use
2363 <code>git stash</code> to stash away the not-yet-committed changes
2364 after each commit, test, and amend the commit if fixes are necessary.</p></div>
2365 </div>
2366 </div>
2367 <div class="sect1">
2368 <h2 id="_recovering_from_upstream_rebase">RECOVERING FROM UPSTREAM REBASE</h2>
2369 <div class="sectionbody">
2370 <div class="paragraph"><p>Rebasing (or any other form of rewriting) a branch that others have
2371 based work on is a bad idea: anyone downstream of it is forced to
2372 manually fix their history. This section explains how to do the fix
2373 from the downstream&#8217;s point of view. The real fix, however, would be
2374 to avoid rebasing the upstream in the first place.</p></div>
2375 <div class="paragraph"><p>To illustrate, suppose you are in a situation where someone develops a
2376 <em>subsystem</em> branch, and you are working on a <em>topic</em> that is dependent
2377 on this <em>subsystem</em>. You might end up with a history like the
2378 following:</p></div>
2379 <div class="listingblock">
2380 <div class="content">
2381 <pre><code> o---o---o---o---o---o---o---o master
2383 o---o---o---o---o subsystem
2385 *---*---* topic</code></pre>
2386 </div></div>
2387 <div class="paragraph"><p>If <em>subsystem</em> is rebased against <em>master</em>, the following happens:</p></div>
2388 <div class="listingblock">
2389 <div class="content">
2390 <pre><code> o---o---o---o---o---o---o---o master
2392 o---o---o---o---o o'--o'--o'--o'--o' subsystem
2394 *---*---* topic</code></pre>
2395 </div></div>
2396 <div class="paragraph"><p>If you now continue development as usual, and eventually merge <em>topic</em>
2397 to <em>subsystem</em>, the commits from <em>subsystem</em> will remain duplicated forever:</p></div>
2398 <div class="listingblock">
2399 <div class="content">
2400 <pre><code> o---o---o---o---o---o---o---o master
2402 o---o---o---o---o o'--o'--o'--o'--o'--M subsystem
2404 *---*---*-..........-*--* topic</code></pre>
2405 </div></div>
2406 <div class="paragraph"><p>Such duplicates are generally frowned upon because they clutter up
2407 history, making it harder to follow. To clean things up, you need to
2408 transplant the commits on <em>topic</em> to the new <em>subsystem</em> tip, i.e.,
2409 rebase <em>topic</em>. This becomes a ripple effect: anyone downstream from
2410 <em>topic</em> is forced to rebase too, and so on!</p></div>
2411 <div class="paragraph"><p>There are two kinds of fixes, discussed in the following subsections:</p></div>
2412 <div class="dlist"><dl>
2413 <dt class="hdlist1">
2414 Easy case: The changes are literally the same.
2415 </dt>
2416 <dd>
2418 This happens if the <em>subsystem</em> rebase was a simple rebase and
2419 had no conflicts.
2420 </p>
2421 </dd>
2422 <dt class="hdlist1">
2423 Hard case: The changes are not the same.
2424 </dt>
2425 <dd>
2427 This happens if the <em>subsystem</em> rebase had conflicts, or used
2428 <code>--interactive</code> to omit, edit, squash, or fixup commits; or
2429 if the upstream used one of <code>commit --amend</code>, <code>reset</code>, or
2430 a full history rewriting command like
2431 <a href="https://github.com/newren/git-filter-repo"><code>filter-repo</code></a>.
2432 </p>
2433 </dd>
2434 </dl></div>
2435 <div class="sect2">
2436 <h3 id="_the_easy_case">The easy case</h3>
2437 <div class="paragraph"><p>Only works if the changes (patch IDs based on the diff contents) on
2438 <em>subsystem</em> are literally the same before and after the rebase
2439 <em>subsystem</em> did.</p></div>
2440 <div class="paragraph"><p>In that case, the fix is easy because <em>git rebase</em> knows to skip
2441 changes that are already present in the new upstream (unless
2442 <code>--reapply-cherry-picks</code> is given). So if you say
2443 (assuming you&#8217;re on <em>topic</em>)</p></div>
2444 <div class="listingblock">
2445 <div class="content">
2446 <pre><code> $ git rebase subsystem</code></pre>
2447 </div></div>
2448 <div class="paragraph"><p>you will end up with the fixed history</p></div>
2449 <div class="listingblock">
2450 <div class="content">
2451 <pre><code> o---o---o---o---o---o---o---o master
2453 o'--o'--o'--o'--o' subsystem
2455 *---*---* topic</code></pre>
2456 </div></div>
2457 </div>
2458 <div class="sect2">
2459 <h3 id="_the_hard_case">The hard case</h3>
2460 <div class="paragraph"><p>Things get more complicated if the <em>subsystem</em> changes do not exactly
2461 correspond to the ones before the rebase.</p></div>
2462 <div class="admonitionblock">
2463 <table><tr>
2464 <td class="icon">
2465 <div class="title">Note</div>
2466 </td>
2467 <td class="content">While an "easy case recovery" sometimes appears to be successful
2468 even in the hard case, it may have unintended consequences. For
2469 example, a commit that was removed via <code>git rebase
2470 --interactive</code> will be <strong>resurrected</strong>!</td>
2471 </tr></table>
2472 </div>
2473 <div class="paragraph"><p>The idea is to manually tell <code>git rebase</code> "where the old <em>subsystem</em>
2474 ended and your <em>topic</em> began", that is, what the old merge base
2475 between them was. You will have to find a way to name the last commit
2476 of the old <em>subsystem</em>, for example:</p></div>
2477 <div class="ulist"><ul>
2478 <li>
2480 With the <em>subsystem</em> reflog: after <code>git fetch</code>, the old tip of
2481 <em>subsystem</em> is at <code>subsystem@{1}</code>. Subsequent fetches will
2482 increase the number. (See <a href="git-reflog.html">git-reflog(1)</a>.)
2483 </p>
2484 </li>
2485 <li>
2487 Relative to the tip of <em>topic</em>: knowing that your <em>topic</em> has three
2488 commits, the old tip of <em>subsystem</em> must be <code>topic~3</code>.
2489 </p>
2490 </li>
2491 </ul></div>
2492 <div class="paragraph"><p>You can then transplant the old <code>subsystem..topic</code> to the new tip by
2493 saying (for the reflog case, and assuming you are on <em>topic</em> already):</p></div>
2494 <div class="listingblock">
2495 <div class="content">
2496 <pre><code> $ git rebase --onto subsystem subsystem@{1}</code></pre>
2497 </div></div>
2498 <div class="paragraph"><p>The ripple effect of a "hard case" recovery is especially bad:
2499 <em>everyone</em> downstream from <em>topic</em> will now have to perform a "hard
2500 case" recovery too!</p></div>
2501 </div>
2502 </div>
2503 </div>
2504 <div class="sect1">
2505 <h2 id="_rebasing_merges">REBASING MERGES</h2>
2506 <div class="sectionbody">
2507 <div class="paragraph"><p>The interactive rebase command was originally designed to handle
2508 individual patch series. As such, it makes sense to exclude merge
2509 commits from the todo list, as the developer may have merged the
2510 then-current <code>master</code> while working on the branch, only to rebase
2511 all the commits onto <code>master</code> eventually (skipping the merge
2512 commits).</p></div>
2513 <div class="paragraph"><p>However, there are legitimate reasons why a developer may want to
2514 recreate merge commits: to keep the branch structure (or "commit
2515 topology") when working on multiple, inter-related branches.</p></div>
2516 <div class="paragraph"><p>In the following example, the developer works on a topic branch that
2517 refactors the way buttons are defined, and on another topic branch
2518 that uses that refactoring to implement a "Report a bug" button. The
2519 output of <code>git log --graph --format=%s -5</code> may look like this:</p></div>
2520 <div class="listingblock">
2521 <div class="content">
2522 <pre><code>* Merge branch 'report-a-bug'
2524 | * Add the feedback button
2525 * | Merge branch 'refactor-button'
2526 |\ \
2527 | |/
2528 | * Use the Button class for all buttons
2529 | * Extract a generic Button class from the DownloadButton one</code></pre>
2530 </div></div>
2531 <div class="paragraph"><p>The developer might want to rebase those commits to a newer <code>master</code>
2532 while keeping the branch topology, for example when the first topic
2533 branch is expected to be integrated into <code>master</code> much earlier than the
2534 second one, say, to resolve merge conflicts with changes to the
2535 DownloadButton class that made it into <code>master</code>.</p></div>
2536 <div class="paragraph"><p>This rebase can be performed using the <code>--rebase-merges</code> option.
2537 It will generate a todo list looking like this:</p></div>
2538 <div class="listingblock">
2539 <div class="content">
2540 <pre><code>label onto
2542 # Branch: refactor-button
2543 reset onto
2544 pick 123456 Extract a generic Button class from the DownloadButton one
2545 pick 654321 Use the Button class for all buttons
2546 label refactor-button
2548 # Branch: report-a-bug
2549 reset refactor-button # Use the Button class for all buttons
2550 pick abcdef Add the feedback button
2551 label report-a-bug
2553 reset onto
2554 merge -C a1b2c3 refactor-button # Merge 'refactor-button'
2555 merge -C 6f5e4d report-a-bug # Merge 'report-a-bug'</code></pre>
2556 </div></div>
2557 <div class="paragraph"><p>In contrast to a regular interactive rebase, there are <code>label</code>, <code>reset</code>
2558 and <code>merge</code> commands in addition to <code>pick</code> ones.</p></div>
2559 <div class="paragraph"><p>The <code>label</code> command associates a label with the current HEAD when that
2560 command is executed. These labels are created as worktree-local refs
2561 (<code>refs/rewritten/&lt;label&gt;</code>) that will be deleted when the rebase
2562 finishes. That way, rebase operations in multiple worktrees linked to
2563 the same repository do not interfere with one another. If the <code>label</code>
2564 command fails, it is rescheduled immediately, with a helpful message how
2565 to proceed.</p></div>
2566 <div class="paragraph"><p>The <code>reset</code> command resets the HEAD, index and worktree to the specified
2567 revision. It is similar to an <code>exec git reset --hard &lt;label&gt;</code>, but
2568 refuses to overwrite untracked files. If the <code>reset</code> command fails, it is
2569 rescheduled immediately, with a helpful message how to edit the todo list
2570 (this typically happens when a <code>reset</code> command was inserted into the todo
2571 list manually and contains a typo).</p></div>
2572 <div class="paragraph"><p>The <code>merge</code> command will merge the specified revision(s) into whatever
2573 is HEAD at that time. With <code>-C &lt;original-commit&gt;</code>, the commit message of
2574 the specified merge commit will be used. When the <code>-C</code> is changed to
2575 a lower-case <code>-c</code>, the message will be opened in an editor after a
2576 successful merge so that the user can edit the message.</p></div>
2577 <div class="paragraph"><p>If a <code>merge</code> command fails for any reason other than merge conflicts (i.e.
2578 when the merge operation did not even start), it is rescheduled immediately.</p></div>
2579 <div class="paragraph"><p>By default, the <code>merge</code> command will use the <code>ort</code> merge strategy for
2580 regular merges, and <code>octopus</code> for octopus merges. One can specify a
2581 default strategy for all merges using the <code>--strategy</code> argument when
2582 invoking rebase, or can override specific merges in the interactive
2583 list of commands by using an <code>exec</code> command to call <code>git merge</code>
2584 explicitly with a <code>--strategy</code> argument. Note that when calling <code>git
2585 merge</code> explicitly like this, you can make use of the fact that the
2586 labels are worktree-local refs (the ref <code>refs/rewritten/onto</code> would
2587 correspond to the label <code>onto</code>, for example) in order to refer to the
2588 branches you want to merge.</p></div>
2589 <div class="paragraph"><p>Note: the first command (<code>label onto</code>) labels the revision onto which
2590 the commits are rebased; The name <code>onto</code> is just a convention, as a nod
2591 to the <code>--onto</code> option.</p></div>
2592 <div class="paragraph"><p>It is also possible to introduce completely new merge commits from scratch
2593 by adding a command of the form <code>merge &lt;merge-head&gt;</code>. This form will
2594 generate a tentative commit message and always open an editor to let the
2595 user edit it. This can be useful e.g. when a topic branch turns out to
2596 address more than a single concern and wants to be split into two or
2597 even more topic branches. Consider this todo list:</p></div>
2598 <div class="listingblock">
2599 <div class="content">
2600 <pre><code>pick 192837 Switch from GNU Makefiles to CMake
2601 pick 5a6c7e Document the switch to CMake
2602 pick 918273 Fix detection of OpenSSL in CMake
2603 pick afbecd http: add support for TLS v1.3
2604 pick fdbaec Fix detection of cURL in CMake on Windows</code></pre>
2605 </div></div>
2606 <div class="paragraph"><p>The one commit in this list that is not related to CMake may very well
2607 have been motivated by working on fixing all those bugs introduced by
2608 switching to CMake, but it addresses a different concern. To split this
2609 branch into two topic branches, the todo list could be edited like this:</p></div>
2610 <div class="listingblock">
2611 <div class="content">
2612 <pre><code>label onto
2614 pick afbecd http: add support for TLS v1.3
2615 label tlsv1.3
2617 reset onto
2618 pick 192837 Switch from GNU Makefiles to CMake
2619 pick 918273 Fix detection of OpenSSL in CMake
2620 pick fdbaec Fix detection of cURL in CMake on Windows
2621 pick 5a6c7e Document the switch to CMake
2622 label cmake
2624 reset onto
2625 merge tlsv1.3
2626 merge cmake</code></pre>
2627 </div></div>
2628 </div>
2629 </div>
2630 <div class="sect1">
2631 <h2 id="_configuration">CONFIGURATION</h2>
2632 <div class="sectionbody">
2633 <div class="paragraph"><p>Everything below this line in this section is selectively included
2634 from the <a href="git-config.html">git-config(1)</a> documentation. The content is the same
2635 as what&#8217;s found there:</p></div>
2636 <div class="dlist"><dl>
2637 <dt class="hdlist1">
2638 rebase.backend
2639 </dt>
2640 <dd>
2642 Default backend to use for rebasing. Possible choices are
2643 <em>apply</em> or <em>merge</em>. In the future, if the merge backend gains
2644 all remaining capabilities of the apply backend, this setting
2645 may become unused.
2646 </p>
2647 </dd>
2648 <dt class="hdlist1">
2649 rebase.stat
2650 </dt>
2651 <dd>
2653 Whether to show a diffstat of what changed upstream since the last
2654 rebase. False by default.
2655 </p>
2656 </dd>
2657 <dt class="hdlist1">
2658 rebase.autoSquash
2659 </dt>
2660 <dd>
2662 If set to true enable <code>--autosquash</code> option by default.
2663 </p>
2664 </dd>
2665 <dt class="hdlist1">
2666 rebase.autoStash
2667 </dt>
2668 <dd>
2670 When set to true, automatically create a temporary stash entry
2671 before the operation begins, and apply it after the operation
2672 ends. This means that you can run rebase on a dirty worktree.
2673 However, use with care: the final stash application after a
2674 successful rebase might result in non-trivial conflicts.
2675 This option can be overridden by the <code>--no-autostash</code> and
2676 <code>--autostash</code> options of <a href="git-rebase.html">git-rebase(1)</a>.
2677 Defaults to false.
2678 </p>
2679 </dd>
2680 <dt class="hdlist1">
2681 rebase.updateRefs
2682 </dt>
2683 <dd>
2685 If set to true enable <code>--update-refs</code> option by default.
2686 </p>
2687 </dd>
2688 <dt class="hdlist1">
2689 rebase.missingCommitsCheck
2690 </dt>
2691 <dd>
2693 If set to "warn", git rebase -i will print a warning if some
2694 commits are removed (e.g. a line was deleted), however the
2695 rebase will still proceed. If set to "error", it will print
2696 the previous warning and stop the rebase, <em>git rebase
2697 --edit-todo</em> can then be used to correct the error. If set to
2698 "ignore", no checking is done.
2699 To drop a commit without warning or error, use the <code>drop</code>
2700 command in the todo list.
2701 Defaults to "ignore".
2702 </p>
2703 </dd>
2704 <dt class="hdlist1">
2705 rebase.instructionFormat
2706 </dt>
2707 <dd>
2709 A format string, as specified in <a href="git-log.html">git-log(1)</a>, to be used for the
2710 todo list during an interactive rebase. The format will
2711 automatically have the long commit hash prepended to the format.
2712 </p>
2713 </dd>
2714 <dt class="hdlist1">
2715 rebase.abbreviateCommands
2716 </dt>
2717 <dd>
2719 If set to true, <code>git rebase</code> will use abbreviated command names in the
2720 todo list resulting in something like this:
2721 </p>
2722 <div class="listingblock">
2723 <div class="content">
2724 <pre><code> p deadbee The oneline of the commit
2725 p fa1afe1 The oneline of the next commit
2726 ...</code></pre>
2727 </div></div>
2728 <div class="paragraph"><p>instead of:</p></div>
2729 <div class="listingblock">
2730 <div class="content">
2731 <pre><code> pick deadbee The oneline of the commit
2732 pick fa1afe1 The oneline of the next commit
2733 ...</code></pre>
2734 </div></div>
2735 <div class="paragraph"><p>Defaults to false.</p></div>
2736 </dd>
2737 <dt class="hdlist1">
2738 rebase.rescheduleFailedExec
2739 </dt>
2740 <dd>
2742 Automatically reschedule <code>exec</code> commands that failed. This only makes
2743 sense in interactive mode (or when an <code>--exec</code> option was provided).
2744 This is the same as specifying the <code>--reschedule-failed-exec</code> option.
2745 </p>
2746 </dd>
2747 <dt class="hdlist1">
2748 rebase.forkPoint
2749 </dt>
2750 <dd>
2752 If set to false set <code>--no-fork-point</code> option by default.
2753 </p>
2754 </dd>
2755 <dt class="hdlist1">
2756 rebase.rebaseMerges
2757 </dt>
2758 <dd>
2760 Whether and how to set the <code>--rebase-merges</code> option by default. Can
2761 be <code>rebase-cousins</code>, <code>no-rebase-cousins</code>, or a boolean. Setting to
2762 true or to <code>no-rebase-cousins</code> is equivalent to
2763 <code>--rebase-merges=no-rebase-cousins</code>, setting to <code>rebase-cousins</code> is
2764 equivalent to <code>--rebase-merges=rebase-cousins</code>, and setting to false is
2765 equivalent to <code>--no-rebase-merges</code>. Passing <code>--rebase-merges</code> on the
2766 command line, with or without an argument, overrides any
2767 <code>rebase.rebaseMerges</code> configuration.
2768 </p>
2769 </dd>
2770 <dt class="hdlist1">
2771 rebase.maxLabelLength
2772 </dt>
2773 <dd>
2775 When generating label names from commit subjects, truncate the names to
2776 this length. By default, the names are truncated to a little less than
2777 <code>NAME_MAX</code> (to allow e.g. <code>.lock</code> files to be written for the
2778 corresponding loose refs).
2779 </p>
2780 </dd>
2781 <dt class="hdlist1">
2782 sequence.editor
2783 </dt>
2784 <dd>
2786 Text editor used by <code>git rebase -i</code> for editing the rebase instruction file.
2787 The value is meant to be interpreted by the shell when it is used.
2788 It can be overridden by the <code>GIT_SEQUENCE_EDITOR</code> environment variable.
2789 When not configured, the default commit message editor is used instead.
2790 </p>
2791 </dd>
2792 </dl></div>
2793 </div>
2794 </div>
2795 <div class="sect1">
2796 <h2 id="_git">GIT</h2>
2797 <div class="sectionbody">
2798 <div class="paragraph"><p>Part of the <a href="git.html">git(1)</a> suite</p></div>
2799 </div>
2800 </div>
2801 </div>
2802 <div id="footnotes"><hr /></div>
2803 <div id="footer">
2804 <div id="footer-text">
2805 Last updated
2806 2023-04-05 08:17:01 JST
2807 </div>
2808 </div>
2809 </body>
2810 </html>