blob: c67f2245ca64315df03612118705966b5e9de1ad [file] [log] [blame]
Junio C Hamano1a4e8412005-12-27 08:17:231<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
2 "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
4<head>
5<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
Junio C Hamanoba4b9282008-07-06 05:20:316<meta name="generator" content="AsciiDoc 8.2.5" />
Junio C Hamano1a4e8412005-12-27 08:17:237<style type="text/css">
8/* Debug borders */
9p, li, dt, dd, div, pre, h1, h2, h3, h4, h5, h6 {
10/*
11 border: 1px solid red;
12*/
13}
14
15body {
16 margin: 1em 5% 1em 5%;
17}
18
Junio C Hamanoba4b9282008-07-06 05:20:3119a {
20 color: blue;
21 text-decoration: underline;
22}
23a:visited {
24 color: fuchsia;
25}
Junio C Hamano1a4e8412005-12-27 08:17:2326
27em {
28 font-style: italic;
29}
30
31strong {
32 font-weight: bold;
33}
34
35tt {
36 color: navy;
37}
38
39h1, h2, h3, h4, h5, h6 {
40 color: #527bbd;
41 font-family: sans-serif;
42 margin-top: 1.2em;
43 margin-bottom: 0.5em;
44 line-height: 1.3;
45}
46
Junio C Hamanoba4b9282008-07-06 05:20:3147h1, h2, h3 {
Junio C Hamano1a4e8412005-12-27 08:17:2348 border-bottom: 2px solid silver;
49}
50h2 {
Junio C Hamano1a4e8412005-12-27 08:17:2351 padding-top: 0.5em;
52}
Junio C Hamanoba4b9282008-07-06 05:20:3153h3 {
54 float: left;
55}
56h3 + * {
57 clear: left;
58}
Junio C Hamano1a4e8412005-12-27 08:17:2359
60div.sectionbody {
61 font-family: serif;
62 margin-left: 0;
63}
64
65hr {
66 border: 1px solid silver;
67}
68
69p {
70 margin-top: 0.5em;
71 margin-bottom: 0.5em;
72}
73
74pre {
75 padding: 0;
76 margin: 0;
77}
78
79span#author {
80 color: #527bbd;
81 font-family: sans-serif;
82 font-weight: bold;
Junio C Hamanoba4b9282008-07-06 05:20:3183 font-size: 1.1em;
Junio C Hamano1a4e8412005-12-27 08:17:2384}
85span#email {
86}
87span#revision {
88 font-family: sans-serif;
89}
90
91div#footer {
92 font-family: sans-serif;
93 font-size: small;
94 border-top: 2px solid silver;
95 padding-top: 0.5em;
96 margin-top: 4.0em;
97}
98div#footer-text {
99 float: left;
100 padding-bottom: 0.5em;
101}
102div#footer-badges {
103 float: right;
104 padding-bottom: 0.5em;
105}
106
107div#preamble,
108div.tableblock, div.imageblock, div.exampleblock, div.verseblock,
109div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock,
110div.admonitionblock {
111 margin-right: 10%;
112 margin-top: 1.5em;
113 margin-bottom: 1.5em;
114}
115div.admonitionblock {
116 margin-top: 2.5em;
117 margin-bottom: 2.5em;
118}
119
120div.content { /* Block element content. */
121 padding: 0;
122}
123
124/* Block element titles. */
125div.title, caption.title {
126 font-family: sans-serif;
127 font-weight: bold;
128 text-align: left;
129 margin-top: 1.0em;
130 margin-bottom: 0.5em;
131}
132div.title + * {
133 margin-top: 0;
134}
135
136td div.title:first-child {
137 margin-top: 0.0em;
138}
139div.content div.title:first-child {
140 margin-top: 0.0em;
141}
142div.content + div.title {
143 margin-top: 0.0em;
144}
145
146div.sidebarblock > div.content {
147 background: #ffffee;
148 border: 1px solid silver;
149 padding: 0.5em;
150}
151
Junio C Hamanoba4b9282008-07-06 05:20:31152div.listingblock {
153 margin-right: 0%;
154}
Junio C Hamano1a4e8412005-12-27 08:17:23155div.listingblock > div.content {
156 border: 1px solid silver;
157 background: #f4f4f4;
158 padding: 0.5em;
159}
160
161div.quoteblock > div.content {
162 padding-left: 2.0em;
163}
Junio C Hamanoba4b9282008-07-06 05:20:31164
165div.attribution {
Junio C Hamano1a4e8412005-12-27 08:17:23166 text-align: right;
167}
Junio C Hamanoba4b9282008-07-06 05:20:31168div.verseblock + div.attribution {
169 text-align: left;
170}
Junio C Hamano1a4e8412005-12-27 08:17:23171
172div.admonitionblock .icon {
173 vertical-align: top;
174 font-size: 1.1em;
175 font-weight: bold;
176 text-decoration: underline;
177 color: #527bbd;
178 padding-right: 0.5em;
179}
180div.admonitionblock td.content {
181 padding-left: 0.5em;
182 border-left: 2px solid silver;
183}
184
185div.exampleblock > div.content {
186 border-left: 2px solid silver;
187 padding: 0.5em;
188}
189
190div.verseblock div.content {
191 white-space: pre;
192}
193
194div.imageblock div.content { padding-left: 0; }
195div.imageblock img { border: 1px solid silver; }
196span.image img { border-style: none; }
197
198dl {
199 margin-top: 0.8em;
200 margin-bottom: 0.8em;
201}
202dt {
203 margin-top: 0.5em;
204 margin-bottom: 0;
205 font-style: italic;
206}
207dd > *:first-child {
208 margin-top: 0;
209}
210
211ul, ol {
212 list-style-position: outside;
213}
Junio C Hamanoba4b9282008-07-06 05:20:31214div.olist2 ol {
Junio C Hamano1a4e8412005-12-27 08:17:23215 list-style-type: lower-alpha;
216}
217
218div.tableblock > table {
Junio C Hamanoba4b9282008-07-06 05:20:31219 border: 3px solid #527bbd;
Junio C Hamano1a4e8412005-12-27 08:17:23220}
221thead {
222 font-family: sans-serif;
223 font-weight: bold;
224}
225tfoot {
226 font-weight: bold;
227}
228
229div.hlist {
230 margin-top: 0.8em;
231 margin-bottom: 0.8em;
232}
Junio C Hamanoba4b9282008-07-06 05:20:31233div.hlist td {
234 padding-bottom: 5px;
235}
Junio C Hamano1a4e8412005-12-27 08:17:23236td.hlist1 {
237 vertical-align: top;
238 font-style: italic;
239 padding-right: 0.8em;
240}
241td.hlist2 {
242 vertical-align: top;
243}
244
245@media print {
246 div#footer-badges { display: none; }
247}
Junio C Hamanoba4b9282008-07-06 05:20:31248
249div#toctitle {
250 color: #527bbd;
251 font-family: sans-serif;
252 font-size: 1.1em;
253 font-weight: bold;
254 margin-top: 1.0em;
255 margin-bottom: 0.1em;
256}
257
258div.toclevel1, div.toclevel2, div.toclevel3, div.toclevel4 {
259 margin-top: 0;
260 margin-bottom: 0;
261}
262div.toclevel2 {
263 margin-left: 2em;
264 font-size: 0.9em;
265}
266div.toclevel3 {
267 margin-left: 4em;
268 font-size: 0.9em;
269}
270div.toclevel4 {
271 margin-left: 6em;
272 font-size: 0.9em;
273}
274include1::./stylesheets/xhtml11-manpage.css[]
Junio C Hamano1a4e8412005-12-27 08:17:23275/* Workarounds for IE6's broken and incomplete CSS2. */
276
277div.sidebar-content {
278 background: #ffffee;
279 border: 1px solid silver;
280 padding: 0.5em;
281}
282div.sidebar-title, div.image-title {
283 font-family: sans-serif;
284 font-weight: bold;
285 margin-top: 0.0em;
286 margin-bottom: 0.5em;
287}
288
289div.listingblock div.content {
290 border: 1px solid silver;
291 background: #f4f4f4;
292 padding: 0.5em;
293}
294
295div.quoteblock-content {
296 padding-left: 2.0em;
297}
298
299div.exampleblock-content {
300 border-left: 2px solid silver;
301 padding-left: 0.5em;
302}
Junio C Hamanoba4b9282008-07-06 05:20:31303
304/* IE6 sets dynamically generated links as visited. */
305div#toc a:visited { color: blue; }
Junio C Hamano1a4e8412005-12-27 08:17:23306</style>
307<title>git-rebase(1)</title>
308</head>
309<body>
310<div id="header">
311<h1>
312git-rebase(1) Manual Page
313</h1>
314<h2>NAME</h2>
315<div class="sectionbody">
316<p>git-rebase -
Junio C Hamano7c73c662007-01-19 00:37:50317 Forward-port local commits to the updated upstream head
Junio C Hamano1a4e8412005-12-27 08:17:23318</p>
319</div>
320</div>
321<h2>SYNOPSIS</h2>
322<div class="sectionbody">
Junio C Hamanoa9b8d242007-05-19 04:51:55323<div class="verseblock">
Junio C Hamanobd53dbf2009-01-18 18:26:37324<div class="content"><em>git rebase</em> [-i | --interactive] [options] [--onto &lt;newbase&gt;]
325 &lt;upstream&gt; [&lt;branch&gt;]
326<em>git rebase</em> [-i | --interactive] [options] --onto &lt;newbase&gt;
327 --root [&lt;branch&gt;]</div></div>
328<div class="para"><p><em>git rebase</em> --continue | --skip | --abort</p></div>
Junio C Hamano1a4e8412005-12-27 08:17:23329</div>
Junio C Hamanoba4b9282008-07-06 05:20:31330<h2 id="_description">DESCRIPTION</h2>
Junio C Hamano1a4e8412005-12-27 08:17:23331<div class="sectionbody">
Junio C Hamanoba4b9282008-07-06 05:20:31332<div class="para"><p>If &lt;branch&gt; is specified, <em>git-rebase</em> will perform an automatic
Junio C Hamano89d4e0f2007-02-18 00:34:59333<tt>git checkout &lt;branch&gt;</tt> before doing anything else. Otherwise
Junio C Hamanoba4b9282008-07-06 05:20:31334it remains on the current branch.</p></div>
335<div class="para"><p>All changes made by commits in the current branch but that are not
Junio C Hamano89d4e0f2007-02-18 00:34:59336in &lt;upstream&gt; are saved to a temporary area. This is the same set
Junio C Hamanobd53dbf2009-01-18 18:26:37337of commits that would be shown by <tt>git log &lt;upstream&gt;..HEAD</tt> (or
338<tt>git log HEAD</tt>, if --root is specified).</p></div>
Junio C Hamanoba4b9282008-07-06 05:20:31339<div class="para"><p>The current branch is reset to &lt;upstream&gt;, or &lt;newbase&gt; if the
Junio C Hamano89d4e0f2007-02-18 00:34:59340--onto option was supplied. This has the exact same effect as
Junio C Hamano38ddcce2008-07-15 15:49:03341<tt>git reset --hard &lt;upstream&gt;</tt> (or &lt;newbase&gt;). ORIG_HEAD is set
342to point at the tip of the branch before the reset.</p></div>
Junio C Hamanoba4b9282008-07-06 05:20:31343<div class="para"><p>The commits that were previously saved into the temporary area are
Junio C Hamano764a6672007-10-23 01:23:31344then reapplied to the current branch, one by one, in order. Note that
345any commits in HEAD which introduce the same textual changes as a commit
346in HEAD..&lt;upstream&gt; are omitted (i.e., a patch already accepted upstream
Junio C Hamanoba4b9282008-07-06 05:20:31347with a different commit message or timestamp will be skipped).</p></div>
348<div class="para"><p>It is possible that a merge failure will prevent this process from being
Junio C Hamano6112cad2006-05-02 07:28:06349completely automatic. You will have to resolve any such merge failure
Junio C Hamano6959c6c2006-05-17 10:34:11350and run <tt>git rebase --continue</tt>. Another option is to bypass the commit
351that caused the merge failure with <tt>git rebase --skip</tt>. To restore the
Junio C Hamano0868a302008-07-22 09:20:44352original &lt;branch&gt; and remove the .git/rebase-apply working files, use the
353command <tt>git rebase --abort</tt> instead.</p></div>
Junio C Hamanoba4b9282008-07-06 05:20:31354<div class="para"><p>Assume the following history exists and the current branch is "topic":</p></div>
Junio C Hamano6112cad2006-05-02 07:28:06355<div class="listingblock">
Junio C Hamano7e9f6b72006-02-22 10:44:55356<div class="content">
Junio C Hamano6112cad2006-05-02 07:28:06357<pre><tt> A---B---C topic
358 /
359 D---E---F---G master</tt></pre>
Junio C Hamano7e9f6b72006-02-22 10:44:55360</div></div>
Junio C Hamanoba4b9282008-07-06 05:20:31361<div class="para"><p>From this point, the result of either of the following commands:</p></div>
Junio C Hamano7e9f6b72006-02-22 10:44:55362<div class="literalblock">
363<div class="content">
Junio C Hamanofce7c7e2008-07-02 03:06:38364<pre><tt>git rebase master
365git rebase master topic</tt></pre>
Junio C Hamano7e9f6b72006-02-22 10:44:55366</div></div>
Junio C Hamanoba4b9282008-07-06 05:20:31367<div class="para"><p>would be:</p></div>
Junio C Hamano6112cad2006-05-02 07:28:06368<div class="listingblock">
Junio C Hamano7e9f6b72006-02-22 10:44:55369<div class="content">
Junio C Hamano6112cad2006-05-02 07:28:06370<pre><tt> A'--B'--C' topic
371 /
372 D---E---F---G master</tt></pre>
Junio C Hamano7e9f6b72006-02-22 10:44:55373</div></div>
Junio C Hamanoba4b9282008-07-06 05:20:31374<div class="para"><p>The latter form is just a short-hand of <tt>git checkout topic</tt>
375followed by <tt>git rebase master</tt>.</p></div>
376<div class="para"><p>If the upstream branch already contains a change you have made (e.g.,
Junio C Hamano764a6672007-10-23 01:23:31377because you mailed a patch which was applied upstream), then that commit
Junio C Hamanofce7c7e2008-07-02 03:06:38378will be skipped. For example, running <tt>git rebase master</tt> on the
Junio C Hamano764a6672007-10-23 01:23:31379following history (in which A' and A introduce the same set of changes,
Junio C Hamanoba4b9282008-07-06 05:20:31380but have different committer information):</p></div>
Junio C Hamano764a6672007-10-23 01:23:31381<div class="listingblock">
382<div class="content">
383<pre><tt> A---B---C topic
384 /
385 D---E---A'---F master</tt></pre>
386</div></div>
Junio C Hamanoba4b9282008-07-06 05:20:31387<div class="para"><p>will result in:</p></div>
Junio C Hamano764a6672007-10-23 01:23:31388<div class="listingblock">
389<div class="content">
390<pre><tt> B'---C' topic
391 /
392 D---E---A'---F master</tt></pre>
393</div></div>
Junio C Hamanoba4b9282008-07-06 05:20:31394<div class="para"><p>Here is how you would transplant a topic branch based on one
Junio C Hamanod8c9d432006-11-07 07:19:13395branch to another, to pretend that you forked the topic branch
Junio C Hamanoba4b9282008-07-06 05:20:31396from the latter branch, using <tt>rebase --onto</tt>.</p></div>
397<div class="para"><p>First let's assume your <em>topic</em> is based on branch <em>next</em>.
Junio C Hamanoa476efa2008-10-10 15:31:42398For example, a feature developed in <em>topic</em> depends on some
Junio C Hamanoba4b9282008-07-06 05:20:31399functionality which is found in <em>next</em>.</p></div>
Junio C Hamano6112cad2006-05-02 07:28:06400<div class="listingblock">
Junio C Hamano7e9f6b72006-02-22 10:44:55401<div class="content">
Junio C Hamanod8c9d432006-11-07 07:19:13402<pre><tt> o---o---o---o---o master
403 \
404 o---o---o---o---o next
405 \
406 o---o---o topic</tt></pre>
Junio C Hamano7e9f6b72006-02-22 10:44:55407</div></div>
Junio C Hamanoa476efa2008-10-10 15:31:42408<div class="para"><p>We want to make <em>topic</em> forked from branch <em>master</em>; for example,
409because the functionality on which <em>topic</em> depends was merged into the
410more stable <em>master</em> branch. We want our tree to look like this:</p></div>
Junio C Hamanod8c9d432006-11-07 07:19:13411<div class="listingblock">
412<div class="content">
413<pre><tt> o---o---o---o---o master
414 | \
415 | o'--o'--o' topic
416 \
417 o---o---o---o---o next</tt></pre>
418</div></div>
Junio C Hamanoba4b9282008-07-06 05:20:31419<div class="para"><p>We can get this using the following command:</p></div>
Junio C Hamanod8c9d432006-11-07 07:19:13420<div class="literalblock">
421<div class="content">
Junio C Hamanofce7c7e2008-07-02 03:06:38422<pre><tt>git rebase --onto master next topic</tt></pre>
Junio C Hamanod8c9d432006-11-07 07:19:13423</div></div>
Junio C Hamanoba4b9282008-07-06 05:20:31424<div class="para"><p>Another example of --onto option is to rebase part of a
425branch. If we have the following situation:</p></div>
Junio C Hamanod8c9d432006-11-07 07:19:13426<div class="listingblock">
427<div class="content">
428<pre><tt> H---I---J topicB
429 /
430 E---F---G topicA
431 /
432 A---B---C---D master</tt></pre>
433</div></div>
Junio C Hamanoba4b9282008-07-06 05:20:31434<div class="para"><p>then the command</p></div>
Junio C Hamanod8c9d432006-11-07 07:19:13435<div class="literalblock">
436<div class="content">
Junio C Hamanofce7c7e2008-07-02 03:06:38437<pre><tt>git rebase --onto master topicA topicB</tt></pre>
Junio C Hamanod8c9d432006-11-07 07:19:13438</div></div>
Junio C Hamanoba4b9282008-07-06 05:20:31439<div class="para"><p>would result in:</p></div>
Junio C Hamanod8c9d432006-11-07 07:19:13440<div class="listingblock">
441<div class="content">
442<pre><tt> H'--I'--J' topicB
443 /
444 | E---F---G topicA
445 |/
446 A---B---C---D master</tt></pre>
447</div></div>
Junio C Hamanoba4b9282008-07-06 05:20:31448<div class="para"><p>This is useful when topicB does not depend on topicA.</p></div>
449<div class="para"><p>A range of commits could also be removed with rebase. If we have
450the following situation:</p></div>
Junio C Hamano42f855f2007-02-06 00:09:38451<div class="listingblock">
452<div class="content">
453<pre><tt> E---F---G---H---I---J topicA</tt></pre>
454</div></div>
Junio C Hamanoba4b9282008-07-06 05:20:31455<div class="para"><p>then the command</p></div>
Junio C Hamano42f855f2007-02-06 00:09:38456<div class="literalblock">
457<div class="content">
Junio C Hamanofce7c7e2008-07-02 03:06:38458<pre><tt>git rebase --onto topicA~5 topicA~3 topicA</tt></pre>
Junio C Hamano42f855f2007-02-06 00:09:38459</div></div>
Junio C Hamanoba4b9282008-07-06 05:20:31460<div class="para"><p>would result in the removal of commits F and G:</p></div>
Junio C Hamano42f855f2007-02-06 00:09:38461<div class="listingblock">
462<div class="content">
463<pre><tt> E---H'---I'---J' topicA</tt></pre>
464</div></div>
Junio C Hamanoba4b9282008-07-06 05:20:31465<div class="para"><p>This is useful if F and G were flawed in some way, or should not be
Junio C Hamano42f855f2007-02-06 00:09:38466part of topicA. Note that the argument to --onto and the &lt;upstream&gt;
Junio C Hamanoba4b9282008-07-06 05:20:31467parameter can be any valid commit-ish.</p></div>
468<div class="para"><p>In case of conflict, <em>git-rebase</em> will stop at the first problematic commit
469and leave conflict markers in the tree. You can use <em>git-diff</em> to locate
Junio C Hamano6112cad2006-05-02 07:28:06470the markers (&lt;&lt;&lt;&lt;&lt;&lt;) and make edits to resolve the conflict. For each
471file you edit, you need to tell git that the conflict has been resolved,
Junio C Hamanoba4b9282008-07-06 05:20:31472typically this would be done with</p></div>
Junio C Hamanof02e09f2006-03-27 07:51:03473<div class="literalblock">
474<div class="content">
Junio C Hamano89d4e0f2007-02-18 00:34:59475<pre><tt>git add &lt;filename&gt;</tt></pre>
Junio C Hamano6112cad2006-05-02 07:28:06476</div></div>
Junio C Hamanoba4b9282008-07-06 05:20:31477<div class="para"><p>After resolving the conflict manually and updating the index with the
478desired resolution, you can continue the rebasing process with</p></div>
Junio C Hamano6112cad2006-05-02 07:28:06479<div class="literalblock">
480<div class="content">
481<pre><tt>git rebase --continue</tt></pre>
Junio C Hamanof02e09f2006-03-27 07:51:03482</div></div>
Junio C Hamanoba4b9282008-07-06 05:20:31483<div class="para"><p>Alternatively, you can undo the <em>git-rebase</em> with</p></div>
Junio C Hamanof02e09f2006-03-27 07:51:03484<div class="literalblock">
485<div class="content">
Junio C Hamano6112cad2006-05-02 07:28:06486<pre><tt>git rebase --abort</tt></pre>
Junio C Hamanof02e09f2006-03-27 07:51:03487</div></div>
Junio C Hamano1a4e8412005-12-27 08:17:23488</div>
Junio C Hamanoea6a7642009-03-11 23:56:19489<h2 id="_configuration">CONFIGURATION</h2>
490<div class="sectionbody">
491<div class="vlist"><dl>
492<dt>
493rebase.stat
494</dt>
495<dd>
496<p>
497 Whether to show a diffstat of what changed upstream since the last
498 rebase. False by default.
499</p>
500</dd>
501</dl></div>
502</div>
Junio C Hamanoba4b9282008-07-06 05:20:31503<h2 id="_options">OPTIONS</h2>
Junio C Hamano1a4e8412005-12-27 08:17:23504<div class="sectionbody">
Junio C Hamanoba4b9282008-07-06 05:20:31505<div class="vlist"><dl>
Junio C Hamano1a4e8412005-12-27 08:17:23506<dt>
Junio C Hamano7e9f6b72006-02-22 10:44:55507&lt;newbase&gt;
508</dt>
509<dd>
510<p>
511 Starting point at which to create the new commits. If the
512 --onto option is not specified, the starting point is
Junio C Hamano42f855f2007-02-06 00:09:38513 &lt;upstream&gt;. May be any valid commit, and not just an
514 existing branch name.
Junio C Hamano7e9f6b72006-02-22 10:44:55515</p>
516</dd>
517<dt>
Junio C Hamano1a4e8412005-12-27 08:17:23518&lt;upstream&gt;
519</dt>
520<dd>
521<p>
Junio C Hamano42f855f2007-02-06 00:09:38522 Upstream branch to compare against. May be any valid commit,
523 not just an existing branch name.
Junio C Hamano1a4e8412005-12-27 08:17:23524</p>
525</dd>
526<dt>
Junio C Hamano2b135272006-03-18 07:45:42527&lt;branch&gt;
Junio C Hamano1a4e8412005-12-27 08:17:23528</dt>
529<dd>
530<p>
531 Working branch; defaults to HEAD.
532</p>
533</dd>
Junio C Hamano6112cad2006-05-02 07:28:06534<dt>
535--continue
536</dt>
537<dd>
538<p>
539 Restart the rebasing process after having resolved a merge conflict.
540</p>
541</dd>
542<dt>
543--abort
544</dt>
545<dd>
546<p>
547 Restore the original branch and abort the rebase operation.
548</p>
549</dd>
Junio C Hamano97f518c2006-06-22 19:49:35550<dt>
551--skip
552</dt>
553<dd>
554<p>
555 Restart the rebasing process by skipping the current patch.
Junio C Hamano97f518c2006-06-22 19:49:35556</p>
557</dd>
558<dt>
Junio C Hamanoeb415992008-06-08 22:49:47559-m
560</dt>
561<dt>
562--merge
Junio C Hamano97f518c2006-06-22 19:49:35563</dt>
564<dd>
565<p>
566 Use merging strategies to rebase. When the recursive (default) merge
567 strategy is used, this allows rebase to be aware of renames on the
568 upstream side.
569</p>
Junio C Hamanobf984de2009-11-23 06:11:19570<div class="para"><p>Note that a rebase merge works by replaying each commit from the working
571branch on top of the &lt;upstream&gt; branch. Because of this, when a merge
572conflict happens, the side reported as <em>ours</em> is the so-far rebased
573series, starting with &lt;upstream&gt;, and <em>theirs</em> is the working branch. In
574other words, the sides are swapped.</p></div>
Junio C Hamano97f518c2006-06-22 19:49:35575</dd>
576<dt>
Junio C Hamanoeb415992008-06-08 22:49:47577-s &lt;strategy&gt;
578</dt>
579<dt>
580--strategy=&lt;strategy&gt;
Junio C Hamano97f518c2006-06-22 19:49:35581</dt>
582<dd>
583<p>
Junio C Hamano52d5def2009-05-21 16:27:43584 Use the given merge strategy.
Junio C Hamanobf984de2009-11-23 06:11:19585 If there is no <tt>-s</tt> option <em>git-merge-recursive</em> is used
586 instead. This implies --merge.
Junio C Hamano97f518c2006-06-22 19:49:35587</p>
Junio C Hamanobf984de2009-11-23 06:11:19588<div class="para"><p>Because <em>git-rebase</em> replays each commit from the working branch
589on top of the &lt;upstream&gt; branch using the given strategy, using
590the <em>ours</em> strategy simply discards all patches from the &lt;branch&gt;,
591which makes little sense.</p></div>
Junio C Hamano97f518c2006-06-22 19:49:35592</dd>
Junio C Hamanofbe00522006-10-19 05:58:48593<dt>
Junio C Hamano2c14c8d2009-07-02 03:17:00594-q
595</dt>
596<dt>
597--quiet
598</dt>
599<dd>
600<p>
601 Be quiet. Implies --no-stat.
602</p>
603</dd>
604<dt>
Junio C Hamanoeb415992008-06-08 22:49:47605-v
606</dt>
607<dt>
608--verbose
Junio C Hamanofbe00522006-10-19 05:58:48609</dt>
610<dd>
611<p>
Junio C Hamanoea6a7642009-03-11 23:56:19612 Be verbose. Implies --stat.
613</p>
614</dd>
615<dt>
616--stat
617</dt>
618<dd>
619<p>
620 Show a diffstat of what changed upstream since the last rebase. The
621 diffstat is also controlled by the configuration option rebase.stat.
622</p>
623</dd>
624<dt>
625-n
626</dt>
627<dt>
628--no-stat
629</dt>
630<dd>
631<p>
632 Do not show a diffstat as part of the rebase process.
Junio C Hamanofbe00522006-10-19 05:58:48633</p>
634</dd>
Junio C Hamanod3339982007-02-09 08:38:48635<dt>
Junio C Hamano7d06a8a2008-10-20 05:42:33636--no-verify
637</dt>
638<dd>
639<p>
640 This option bypasses the pre-rebase hook. See also <a href="githooks.html">githooks(5)</a>.
641</p>
642</dd>
643<dt>
Junio C Hamanod3339982007-02-09 08:38:48644-C&lt;n&gt;
645</dt>
646<dd>
647<p>
648 Ensure at least &lt;n&gt; lines of surrounding context match before
649 and after each change. When fewer lines of surrounding
650 context exist they all must match. By default no context is
651 ever ignored.
652</p>
653</dd>
Junio C Hamano1d90cb02007-07-03 07:05:31654<dt>
Junio C Hamanoa973f1c2009-03-19 17:47:52655-f
656</dt>
657<dt>
658--force-rebase
659</dt>
660<dd>
661<p>
662 Force the rebase even if the current branch is a descendant
663 of the commit you are rebasing onto. Normally the command will
664 exit with the message "Current branch is up to date" in such a
665 situation.
666</p>
667</dd>
668<dt>
Junio C Hamanofe24db02009-08-22 05:10:47669--ignore-whitespace
670</dt>
671<dt>
Junio C Hamanof8a79222009-03-01 08:02:50672--whitespace=&lt;option&gt;
Junio C Hamano250f03e2007-09-10 01:33:28673</dt>
674<dd>
675<p>
Junio C Hamanofe24db02009-08-22 05:10:47676 These flag are passed to the <em>git-apply</em> program
Junio C Hamano250f03e2007-09-10 01:33:28677 (see <a href="git-apply.html">git-apply(1)</a>) that applies the patch.
Junio C Hamanoec3b9a72009-02-13 08:45:52678 Incompatible with the --interactive option.
Junio C Hamano250f03e2007-09-10 01:33:28679</p>
680</dd>
681<dt>
Junio C Hamanoa973f1c2009-03-19 17:47:52682--committer-date-is-author-date
683</dt>
684<dt>
685--ignore-date
686</dt>
687<dd>
688<p>
689 These flags are passed to <em>git-am</em> to easily change the dates
690 of the rebased commits (see <a href="git-am.html">git-am(1)</a>).
691</p>
692</dd>
693<dt>
Junio C Hamanoeb415992008-06-08 22:49:47694-i
695</dt>
696<dt>
697--interactive
Junio C Hamano1d90cb02007-07-03 07:05:31698</dt>
699<dd>
700<p>
701 Make a list of the commits which are about to be rebased. Let the
Junio C Hamanodbb64592007-09-01 11:17:39702 user edit that list before rebasing. This mode can also be used to
703 split commits (see SPLITTING COMMITS below).
Junio C Hamano1d90cb02007-07-03 07:05:31704</p>
705</dd>
706<dt>
Junio C Hamanoeb415992008-06-08 22:49:47707-p
708</dt>
709<dt>
710--preserve-merges
Junio C Hamano1d90cb02007-07-03 07:05:31711</dt>
712<dd>
713<p>
Junio C Hamano7d06a8a2008-10-20 05:42:33714 Instead of ignoring merges, try to recreate them.
Junio C Hamano1d90cb02007-07-03 07:05:31715</p>
716</dd>
Junio C Hamanobd53dbf2009-01-18 18:26:37717<dt>
718--root
719</dt>
720<dd>
721<p>
722 Rebase all commits reachable from &lt;branch&gt;, instead of
723 limiting them with an &lt;upstream&gt;. This allows you to rebase
724 the root commit(s) on a branch. Must be used with --onto, and
725 will skip changes already contained in &lt;newbase&gt; (instead of
726 &lt;upstream&gt;). When used together with --preserve-merges, <em>all</em>
727 root commits will be rewritten to have &lt;newbase&gt; as parent
728 instead.
729</p>
730</dd>
Junio C Hamanoba4b9282008-07-06 05:20:31731</dl></div>
Junio C Hamano97f518c2006-06-22 19:49:35732</div>
Junio C Hamanoba4b9282008-07-06 05:20:31733<h2 id="_merge_strategies">MERGE STRATEGIES</h2>
Junio C Hamano97f518c2006-06-22 19:49:35734<div class="sectionbody">
Junio C Hamanoba4b9282008-07-06 05:20:31735<div class="vlist"><dl>
Junio C Hamano97f518c2006-06-22 19:49:35736<dt>
737resolve
738</dt>
739<dd>
740<p>
741 This can only resolve two heads (i.e. the current branch
Junio C Hamano1de75722009-03-26 08:39:38742 and another branch you pulled from) using a 3-way merge
Junio C Hamano97f518c2006-06-22 19:49:35743 algorithm. It tries to carefully detect criss-cross
744 merge ambiguities and is considered generally safe and
745 fast.
746</p>
747</dd>
748<dt>
749recursive
750</dt>
751<dd>
752<p>
Junio C Hamano1de75722009-03-26 08:39:38753 This can only resolve two heads using a 3-way merge
754 algorithm. When there is more than one common
755 ancestor that can be used for 3-way merge, it creates a
Junio C Hamano97f518c2006-06-22 19:49:35756 merged tree of the common ancestors and uses that as
757 the reference tree for the 3-way merge. This has been
758 reported to result in fewer merge conflicts without
759 causing mis-merges by tests done on actual merge commits
760 taken from Linux 2.6 kernel development history.
761 Additionally this can detect and handle merges involving
762 renames. This is the default merge strategy when
763 pulling or merging one branch.
764</p>
765</dd>
766<dt>
767octopus
768</dt>
769<dd>
770<p>
Junio C Hamano1de75722009-03-26 08:39:38771 This resolves cases with more than two heads, but refuses to do
772 a complex merge that needs manual resolution. It is
Junio C Hamano97f518c2006-06-22 19:49:35773 primarily meant to be used for bundling topic branch
774 heads together. This is the default merge strategy when
Junio C Hamano1de75722009-03-26 08:39:38775 pulling or merging more than one branch.
Junio C Hamano97f518c2006-06-22 19:49:35776</p>
777</dd>
778<dt>
779ours
780</dt>
781<dd>
782<p>
Junio C Hamanobf984de2009-11-23 06:11:19783 This resolves any number of heads, but the resulting tree of the
784 merge is always that of the current branch head, effectively
785 ignoring all changes from all other branches. It is meant to
Junio C Hamano97f518c2006-06-22 19:49:35786 be used to supersede old development history of side
787 branches.
788</p>
789</dd>
Junio C Hamanoe6c92032008-03-19 09:24:34790<dt>
791subtree
792</dt>
793<dd>
794<p>
795 This is a modified recursive strategy. When merging trees A and
796 B, if B corresponds to a subtree of A, B is first adjusted to
797 match the tree structure of A, instead of reading the trees at
798 the same level. This adjustment is also done to the common
799 ancestor tree.
800</p>
801</dd>
Junio C Hamanoba4b9282008-07-06 05:20:31802</dl></div>
Junio C Hamano1a4e8412005-12-27 08:17:23803</div>
Junio C Hamanoba4b9282008-07-06 05:20:31804<h2 id="_notes">NOTES</h2>
Junio C Hamano6112cad2006-05-02 07:28:06805<div class="sectionbody">
Junio C Hamano7d06a8a2008-10-20 05:42:33806<div class="para"><p>You should understand the implications of using <em>git-rebase</em> on a
807repository that you share. See also RECOVERING FROM UPSTREAM REBASE
808below.</p></div>
Junio C Hamanoba4b9282008-07-06 05:20:31809<div class="para"><p>When the git-rebase command is run, it will first execute a "pre-rebase"
Junio C Hamano6112cad2006-05-02 07:28:06810hook if one exists. You can use this hook to do sanity checks and
811reject the rebase if it isn't appropriate. Please see the template
Junio C Hamanoba4b9282008-07-06 05:20:31812pre-rebase hook script for an example.</p></div>
813<div class="para"><p>Upon completion, &lt;branch&gt; will be the current branch.</p></div>
Junio C Hamano6112cad2006-05-02 07:28:06814</div>
Junio C Hamanoba4b9282008-07-06 05:20:31815<h2 id="_interactive_mode">INTERACTIVE MODE</h2>
Junio C Hamano1a4e8412005-12-27 08:17:23816<div class="sectionbody">
Junio C Hamanoba4b9282008-07-06 05:20:31817<div class="para"><p>Rebasing interactively means that you have a chance to edit the commits
Junio C Hamano1d90cb02007-07-03 07:05:31818which are rebased. You can reorder the commits, and you can
Junio C Hamanoba4b9282008-07-06 05:20:31819remove them (weeding out bad or otherwise unwanted patches).</p></div>
820<div class="para"><p>The interactive mode is meant for this type of workflow:</p></div>
821<div class="olist"><ol>
Junio C Hamano1d90cb02007-07-03 07:05:31822<li>
823<p>
824have a wonderful idea
825</p>
826</li>
827<li>
828<p>
829hack on the code
830</p>
831</li>
832<li>
833<p>
834prepare a series for submission
835</p>
836</li>
837<li>
838<p>
839submit
840</p>
841</li>
Junio C Hamanoba4b9282008-07-06 05:20:31842</ol></div>
843<div class="para"><p>where point 2. consists of several instances of</p></div>
844<div class="olist2"><ol>
Junio C Hamano1d90cb02007-07-03 07:05:31845<li>
846<p>
847regular use
848</p>
Junio C Hamanoba4b9282008-07-06 05:20:31849<div class="olist"><ol>
Junio C Hamano1d90cb02007-07-03 07:05:31850<li>
851<p>
852finish something worthy of a commit
853</p>
854</li>
855<li>
856<p>
857commit
858</p>
859</li>
Junio C Hamanoba4b9282008-07-06 05:20:31860</ol></div>
Junio C Hamano1d90cb02007-07-03 07:05:31861</li>
862<li>
863<p>
864independent fixup
865</p>
Junio C Hamanoba4b9282008-07-06 05:20:31866<div class="olist"><ol>
Junio C Hamano1d90cb02007-07-03 07:05:31867<li>
868<p>
869realize that something does not work
870</p>
871</li>
872<li>
873<p>
874fix that
875</p>
876</li>
877<li>
878<p>
879commit it
880</p>
881</li>
Junio C Hamanoba4b9282008-07-06 05:20:31882</ol></div>
Junio C Hamano1d90cb02007-07-03 07:05:31883</li>
Junio C Hamanoba4b9282008-07-06 05:20:31884</ol></div>
885<div class="para"><p>Sometimes the thing fixed in b.2. cannot be amended to the not-quite
Junio C Hamano1d90cb02007-07-03 07:05:31886perfect commit it fixes, because that commit is buried deeply in a
887patch series. That is exactly what interactive rebase is for: use it
888after plenty of "a"s and "b"s, by rearranging and editing
Junio C Hamanoba4b9282008-07-06 05:20:31889commits, and squashing multiple commits into one.</p></div>
890<div class="para"><p>Start it with the last commit you want to retain as-is:</p></div>
Junio C Hamano1d90cb02007-07-03 07:05:31891<div class="literalblock">
892<div class="content">
893<pre><tt>git rebase -i &lt;after-this-commit&gt;</tt></pre>
894</div></div>
Junio C Hamanoba4b9282008-07-06 05:20:31895<div class="para"><p>An editor will be fired up with all the commits in your current branch
Junio C Hamano1d90cb02007-07-03 07:05:31896(ignoring merge commits), which come after the given commit. You can
897reorder the commits in this list to your heart's content, and you can
Junio C Hamanoba4b9282008-07-06 05:20:31898remove them. The list looks more or less like this:</p></div>
Junio C Hamano1d90cb02007-07-03 07:05:31899<div class="listingblock">
900<div class="content">
901<pre><tt>pick deadbee The oneline of this commit
902pick fa1afe1 The oneline of the next commit
903...</tt></pre>
904</div></div>
Junio C Hamanoba4b9282008-07-06 05:20:31905<div class="para"><p>The oneline descriptions are purely for your pleasure; <em>git-rebase</em> will
Junio C Hamano1d90cb02007-07-03 07:05:31906not look at them but at the commit names ("deadbee" and "fa1afe1" in this
Junio C Hamanoba4b9282008-07-06 05:20:31907example), so do not delete or edit the names.</p></div>
908<div class="para"><p>By replacing the command "pick" with the command "edit", you can tell
909<em>git-rebase</em> to stop after applying that commit, so that you can edit
Junio C Hamano1d90cb02007-07-03 07:05:31910the files and/or the commit message, amend the commit, and continue
Junio C Hamanoba4b9282008-07-06 05:20:31911rebasing.</p></div>
Junio C Hamano3d23a0a2009-10-19 08:04:30912<div class="para"><p>If you just want to edit the commit message for a commit, replace the
913command "pick" with the command "reword".</p></div>
Junio C Hamanoba4b9282008-07-06 05:20:31914<div class="para"><p>If you want to fold two or more commits into one, replace the command
Junio C Hamano1d90cb02007-07-03 07:05:31915"pick" with "squash" for the second and subsequent commit. If the
916commits had different authors, it will attribute the squashed commit to
Junio C Hamanoba4b9282008-07-06 05:20:31917the author of the first commit.</p></div>
Junio C Hamano3d23a0a2009-10-19 08:04:30918<div class="para"><p><em>git-rebase</em> will stop when "pick" has been replaced with "edit" or
919when a command fails due to merge errors. When you are done editing
920and/or resolving conflicts you can continue with <tt>git rebase --continue</tt>.</p></div>
Junio C Hamanoba4b9282008-07-06 05:20:31921<div class="para"><p>For example, if you want to reorder the last 5 commits, such that what
Junio C Hamano1d90cb02007-07-03 07:05:31922was HEAD~4 becomes the new HEAD. To achieve that, you would call
Junio C Hamanoba4b9282008-07-06 05:20:31923<em>git-rebase</em> like this:</p></div>
Junio C Hamano1d90cb02007-07-03 07:05:31924<div class="listingblock">
925<div class="content">
926<pre><tt>$ git rebase -i HEAD~5</tt></pre>
927</div></div>
Junio C Hamanoba4b9282008-07-06 05:20:31928<div class="para"><p>And move the first patch to the end of the list.</p></div>
929<div class="para"><p>You might want to preserve merges, if you have a history like this:</p></div>
Junio C Hamano1d90cb02007-07-03 07:05:31930<div class="listingblock">
931<div class="content">
932<pre><tt> X
933 \
934 A---M---B
935 /
936---o---O---P---Q</tt></pre>
937</div></div>
Junio C Hamanoba4b9282008-07-06 05:20:31938<div class="para"><p>Suppose you want to rebase the side branch starting at "A" to "Q". Make
939sure that the current HEAD is "B", and call</p></div>
Junio C Hamano1d90cb02007-07-03 07:05:31940<div class="listingblock">
941<div class="content">
942<pre><tt>$ git rebase -i -p --onto Q O</tt></pre>
943</div></div>
944</div>
Junio C Hamanoba4b9282008-07-06 05:20:31945<h2 id="_splitting_commits">SPLITTING COMMITS</h2>
Junio C Hamanodbb64592007-09-01 11:17:39946<div class="sectionbody">
Junio C Hamanoba4b9282008-07-06 05:20:31947<div class="para"><p>In interactive mode, you can mark commits with the action "edit". However,
948this does not necessarily mean that <em>git-rebase</em> expects the result of this
Junio C Hamanodbb64592007-09-01 11:17:39949edit to be exactly one commit. Indeed, you can undo the commit, or you can
Junio C Hamanoba4b9282008-07-06 05:20:31950add other commits. This can be used to split a commit into two:</p></div>
951<div class="ilist"><ul>
Junio C Hamanodbb64592007-09-01 11:17:39952<li>
953<p>
Junio C Hamanofce7c7e2008-07-02 03:06:38954Start an interactive rebase with <tt>git rebase -i &lt;commit&gt;^</tt>, where
Junio C Hamanodbb64592007-09-01 11:17:39955 &lt;commit&gt; is the commit you want to split. In fact, any commit range
956 will do, as long as it contains that commit.
957</p>
958</li>
959<li>
960<p>
961Mark the commit you want to split with the action "edit".
962</p>
963</li>
964<li>
965<p>
Junio C Hamanofce7c7e2008-07-02 03:06:38966When it comes to editing that commit, execute <tt>git reset HEAD^</tt>. The
Junio C Hamanodbb64592007-09-01 11:17:39967 effect is that the HEAD is rewound by one, and the index follows suit.
968 However, the working tree stays the same.
969</p>
970</li>
971<li>
972<p>
973Now add the changes to the index that you want to have in the first
Junio C Hamanofce7c7e2008-07-02 03:06:38974 commit. You can use <tt>git add</tt> (possibly interactively) or
Junio C Hamanoba4b9282008-07-06 05:20:31975 <em>git-gui</em> (or both) to do that.
Junio C Hamanodbb64592007-09-01 11:17:39976</p>
977</li>
978<li>
979<p>
980Commit the now-current index with whatever commit message is appropriate
981 now.
982</p>
983</li>
984<li>
985<p>
986Repeat the last two steps until your working tree is clean.
987</p>
988</li>
989<li>
990<p>
Junio C Hamanofce7c7e2008-07-02 03:06:38991Continue the rebase with <tt>git rebase --continue</tt>.
Junio C Hamanodbb64592007-09-01 11:17:39992</p>
993</li>
Junio C Hamanoba4b9282008-07-06 05:20:31994</ul></div>
995<div class="para"><p>If you are not absolutely sure that the intermediate revisions are
Junio C Hamanodbb64592007-09-01 11:17:39996consistent (they compile, pass the testsuite, etc.) you should use
Junio C Hamanoba4b9282008-07-06 05:20:31997<em>git-stash</em> to stash away the not-yet-committed changes
998after each commit, test, and amend the commit if fixes are necessary.</p></div>
Junio C Hamanodbb64592007-09-01 11:17:39999</div>
Junio C Hamano7d06a8a2008-10-20 05:42:331000<h2 id="_recovering_from_upstream_rebase">RECOVERING FROM UPSTREAM REBASE</h2>
1001<div class="sectionbody">
1002<div class="para"><p>Rebasing (or any other form of rewriting) a branch that others have
1003based work on is a bad idea: anyone downstream of it is forced to
1004manually fix their history. This section explains how to do the fix
1005from the downstream's point of view. The real fix, however, would be
1006to avoid rebasing the upstream in the first place.</p></div>
1007<div class="para"><p>To illustrate, suppose you are in a situation where someone develops a
1008<em>subsystem</em> branch, and you are working on a <em>topic</em> that is dependent
1009on this <em>subsystem</em>. You might end up with a history like the
1010following:</p></div>
1011<div class="listingblock">
1012<div class="content">
1013<pre><tt> o---o---o---o---o---o---o---o---o master
1014 \
1015 o---o---o---o---o subsystem
1016 \
1017 *---*---* topic</tt></pre>
1018</div></div>
1019<div class="para"><p>If <em>subsystem</em> is rebased against <em>master</em>, the following happens:</p></div>
1020<div class="listingblock">
1021<div class="content">
1022<pre><tt> o---o---o---o---o---o---o---o master
1023 \ \
1024 o---o---o---o---o o'--o'--o'--o'--o' subsystem
1025 \
1026 *---*---* topic</tt></pre>
1027</div></div>
1028<div class="para"><p>If you now continue development as usual, and eventually merge <em>topic</em>
1029to <em>subsystem</em>, the commits from <em>subsystem</em> will remain duplicated forever:</p></div>
1030<div class="listingblock">
1031<div class="content">
1032<pre><tt> o---o---o---o---o---o---o---o master
1033 \ \
1034 o---o---o---o---o o'--o'--o'--o'--o'--M subsystem
1035 \ /
1036 *---*---*-..........-*--* topic</tt></pre>
1037</div></div>
1038<div class="para"><p>Such duplicates are generally frowned upon because they clutter up
1039history, making it harder to follow. To clean things up, you need to
1040transplant the commits on <em>topic</em> to the new <em>subsystem</em> tip, i.e.,
1041rebase <em>topic</em>. This becomes a ripple effect: anyone downstream from
1042<em>topic</em> is forced to rebase too, and so on!</p></div>
1043<div class="para"><p>There are two kinds of fixes, discussed in the following subsections:</p></div>
1044<div class="vlist"><dl>
1045<dt>
1046Easy case: The changes are literally the same.
1047</dt>
1048<dd>
1049<p>
1050 This happens if the <em>subsystem</em> rebase was a simple rebase and
1051 had no conflicts.
1052</p>
1053</dd>
1054<dt>
1055Hard case: The changes are not the same.
1056</dt>
1057<dd>
1058<p>
1059 This happens if the <em>subsystem</em> rebase had conflicts, or used
1060 <tt>--interactive</tt> to omit, edit, or squash commits; or if the
1061 upstream used one of <tt>commit --amend</tt>, <tt>reset</tt>, or
1062 <tt>filter-branch</tt>.
1063</p>
1064</dd>
1065</dl></div>
1066<h3 id="_the_easy_case">The easy case</h3><div style="clear:left"></div>
1067<div class="para"><p>Only works if the changes (patch IDs based on the diff contents) on
1068<em>subsystem</em> are literally the same before and after the rebase
1069<em>subsystem</em> did.</p></div>
1070<div class="para"><p>In that case, the fix is easy because <em>git-rebase</em> knows to skip
1071changes that are already present in the new upstream. So if you say
1072(assuming you're on <em>topic</em>)</p></div>
1073<div class="listingblock">
1074<div class="content">
1075<pre><tt> $ git rebase subsystem</tt></pre>
1076</div></div>
1077<div class="para"><p>you will end up with the fixed history</p></div>
1078<div class="listingblock">
1079<div class="content">
1080<pre><tt> o---o---o---o---o---o---o---o master
1081 \
1082 o'--o'--o'--o'--o' subsystem
1083 \
1084 *---*---* topic</tt></pre>
1085</div></div>
1086<h3 id="_the_hard_case">The hard case</h3><div style="clear:left"></div>
1087<div class="para"><p>Things get more complicated if the <em>subsystem</em> changes do not exactly
1088correspond to the ones before the rebase.</p></div>
1089<div class="admonitionblock">
1090<table><tr>
1091<td class="icon">
1092<div class="title">Note</div>
1093</td>
1094<td class="content">While an "easy case recovery" sometimes appears to be successful
1095 even in the hard case, it may have unintended consequences. For
1096 example, a commit that was removed via <tt>git rebase
1097 --interactive</tt> will be <strong>*resurrected</strong>*!</td>
1098</tr></table>
1099</div>
1100<div class="para"><p>The idea is to manually tell <em>git-rebase</em> "where the old <em>subsystem</em>
1101ended and your <em>topic</em> began", that is, what the old merge-base
1102between them was. You will have to find a way to name the last commit
1103of the old <em>subsystem</em>, for example:</p></div>
1104<div class="ilist"><ul>
1105<li>
1106<p>
1107With the <em>subsystem</em> reflog: after <em>git-fetch</em>, the old tip of
1108 <em>subsystem</em> is at <tt>subsystem@{1}</tt>. Subsequent fetches will
1109 increase the number. (See <a href="git-reflog.html">git-reflog(1)</a>.)
1110</p>
1111</li>
1112<li>
1113<p>
1114Relative to the tip of <em>topic</em>: knowing that your <em>topic</em> has three
1115 commits, the old tip of <em>subsystem</em> must be <tt>topic~3</tt>.
1116</p>
1117</li>
1118</ul></div>
1119<div class="para"><p>You can then transplant the old <tt>subsystem..topic</tt> to the new tip by
1120saying (for the reflog case, and assuming you are on <em>topic</em> already):</p></div>
1121<div class="listingblock">
1122<div class="content">
1123<pre><tt> $ git rebase --onto subsystem subsystem@{1}</tt></pre>
1124</div></div>
1125<div class="para"><p>The ripple effect of a "hard case" recovery is especially bad:
1126<em>everyone</em> downstream from <em>topic</em> will now have to perform a "hard
1127case" recovery too!</p></div>
1128</div>
Junio C Hamanoba4b9282008-07-06 05:20:311129<h2 id="_authors">Authors</h2>
Junio C Hamano1d90cb02007-07-03 07:05:311130<div class="sectionbody">
Junio C Hamano0868a302008-07-22 09:20:441131<div class="para"><p>Written by Junio C Hamano &lt;gitster@pobox.com&gt; and
Junio C Hamanoba4b9282008-07-06 05:20:311132Johannes E. Schindelin &lt;johannes.schindelin@gmx.de&gt;</p></div>
Junio C Hamano1a4e8412005-12-27 08:17:231133</div>
Junio C Hamanoba4b9282008-07-06 05:20:311134<h2 id="_documentation">Documentation</h2>
Junio C Hamano1a4e8412005-12-27 08:17:231135<div class="sectionbody">
Junio C Hamanoba4b9282008-07-06 05:20:311136<div class="para"><p>Documentation by Junio C Hamano and the git-list &lt;git@vger.kernel.org&gt;.</p></div>
Junio C Hamano1a4e8412005-12-27 08:17:231137</div>
Junio C Hamanoba4b9282008-07-06 05:20:311138<h2 id="_git">GIT</h2>
Junio C Hamano1a4e8412005-12-27 08:17:231139<div class="sectionbody">
Junio C Hamanoba4b9282008-07-06 05:20:311140<div class="para"><p>Part of the <a href="git.html">git(1)</a> suite</p></div>
Junio C Hamano1a4e8412005-12-27 08:17:231141</div>
1142<div id="footer">
1143<div id="footer-text">
Junio C Hamanofa2ad882009-12-03 09:15:441144Last updated 2009-12-03 09:12:44 UTC
Junio C Hamano1a4e8412005-12-27 08:17:231145</div>
1146</div>
1147</body>
1148</html>