blob: e67b2d42a2f1daf35bbbdcece0504e9aaf31de5f [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 Hamanofce7c7e2008-07-02 03:06:38324<div class="content"><em>git rebase</em> [-i | --interactive] [-v | --verbose] [-m | --merge]
Junio C Hamano4f1d8c42008-03-03 02:01:16325 [-s &lt;strategy&gt; | --strategy=&lt;strategy&gt;]
Junio C Hamano250f03e2007-09-10 01:33:28326 [-C&lt;n&gt;] [ --whitespace=&lt;option&gt;] [-p | --preserve-merges]
327 [--onto &lt;newbase&gt;] &lt;upstream&gt; [&lt;branch&gt;]
Junio C Hamanofce7c7e2008-07-02 03:06:38328<em>git rebase</em> --continue | --skip | --abort</div></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 Hamanoba4b9282008-07-06 05:20:31337of commits that would be shown by <tt>git log &lt;upstream&gt;..HEAD</tt>.</p></div>
338<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:59339--onto option was supplied. This has the exact same effect as
Junio C Hamano38ddcce2008-07-15 15:49:03340<tt>git reset --hard &lt;upstream&gt;</tt> (or &lt;newbase&gt;). ORIG_HEAD is set
341to point at the tip of the branch before the reset.</p></div>
Junio C Hamanoba4b9282008-07-06 05:20:31342<div class="para"><p>The commits that were previously saved into the temporary area are
Junio C Hamano764a6672007-10-23 01:23:31343then reapplied to the current branch, one by one, in order. Note that
344any commits in HEAD which introduce the same textual changes as a commit
345in HEAD..&lt;upstream&gt; are omitted (i.e., a patch already accepted upstream
Junio C Hamanoba4b9282008-07-06 05:20:31346with a different commit message or timestamp will be skipped).</p></div>
347<div class="para"><p>It is possible that a merge failure will prevent this process from being
Junio C Hamano6112cad2006-05-02 07:28:06348completely automatic. You will have to resolve any such merge failure
Junio C Hamano6959c6c2006-05-17 10:34:11349and run <tt>git rebase --continue</tt>. Another option is to bypass the commit
350that caused the merge failure with <tt>git rebase --skip</tt>. To restore the
Junio C Hamano0868a302008-07-22 09:20:44351original &lt;branch&gt; and remove the .git/rebase-apply working files, use the
352command <tt>git rebase --abort</tt> instead.</p></div>
Junio C Hamanoba4b9282008-07-06 05:20:31353<div class="para"><p>Assume the following history exists and the current branch is "topic":</p></div>
Junio C Hamano6112cad2006-05-02 07:28:06354<div class="listingblock">
Junio C Hamano7e9f6b72006-02-22 10:44:55355<div class="content">
Junio C Hamano6112cad2006-05-02 07:28:06356<pre><tt> A---B---C topic
357 /
358 D---E---F---G master</tt></pre>
Junio C Hamano7e9f6b72006-02-22 10:44:55359</div></div>
Junio C Hamanoba4b9282008-07-06 05:20:31360<div class="para"><p>From this point, the result of either of the following commands:</p></div>
Junio C Hamano7e9f6b72006-02-22 10:44:55361<div class="literalblock">
362<div class="content">
Junio C Hamanofce7c7e2008-07-02 03:06:38363<pre><tt>git rebase master
364git rebase master topic</tt></pre>
Junio C Hamano7e9f6b72006-02-22 10:44:55365</div></div>
Junio C Hamanoba4b9282008-07-06 05:20:31366<div class="para"><p>would be:</p></div>
Junio C Hamano6112cad2006-05-02 07:28:06367<div class="listingblock">
Junio C Hamano7e9f6b72006-02-22 10:44:55368<div class="content">
Junio C Hamano6112cad2006-05-02 07:28:06369<pre><tt> A'--B'--C' topic
370 /
371 D---E---F---G master</tt></pre>
Junio C Hamano7e9f6b72006-02-22 10:44:55372</div></div>
Junio C Hamanoba4b9282008-07-06 05:20:31373<div class="para"><p>The latter form is just a short-hand of <tt>git checkout topic</tt>
374followed by <tt>git rebase master</tt>.</p></div>
375<div class="para"><p>If the upstream branch already contains a change you have made (e.g.,
Junio C Hamano764a6672007-10-23 01:23:31376because you mailed a patch which was applied upstream), then that commit
Junio C Hamanofce7c7e2008-07-02 03:06:38377will be skipped. For example, running <tt>git rebase master</tt> on the
Junio C Hamano764a6672007-10-23 01:23:31378following history (in which A' and A introduce the same set of changes,
Junio C Hamanoba4b9282008-07-06 05:20:31379but have different committer information):</p></div>
Junio C Hamano764a6672007-10-23 01:23:31380<div class="listingblock">
381<div class="content">
382<pre><tt> A---B---C topic
383 /
384 D---E---A'---F master</tt></pre>
385</div></div>
Junio C Hamanoba4b9282008-07-06 05:20:31386<div class="para"><p>will result in:</p></div>
Junio C Hamano764a6672007-10-23 01:23:31387<div class="listingblock">
388<div class="content">
389<pre><tt> B'---C' topic
390 /
391 D---E---A'---F master</tt></pre>
392</div></div>
Junio C Hamanoba4b9282008-07-06 05:20:31393<div class="para"><p>Here is how you would transplant a topic branch based on one
Junio C Hamanod8c9d432006-11-07 07:19:13394branch to another, to pretend that you forked the topic branch
Junio C Hamanoba4b9282008-07-06 05:20:31395from the latter branch, using <tt>rebase --onto</tt>.</p></div>
396<div class="para"><p>First let's assume your <em>topic</em> is based on branch <em>next</em>.
Junio C Hamanod8c9d432006-11-07 07:19:13397For example feature developed in <em>topic</em> depends on some
Junio C Hamanoba4b9282008-07-06 05:20:31398functionality which is found in <em>next</em>.</p></div>
Junio C Hamano6112cad2006-05-02 07:28:06399<div class="listingblock">
Junio C Hamano7e9f6b72006-02-22 10:44:55400<div class="content">
Junio C Hamanod8c9d432006-11-07 07:19:13401<pre><tt> o---o---o---o---o master
402 \
403 o---o---o---o---o next
404 \
405 o---o---o topic</tt></pre>
Junio C Hamano7e9f6b72006-02-22 10:44:55406</div></div>
Junio C Hamanoba4b9282008-07-06 05:20:31407<div class="para"><p>We would want to make <em>topic</em> forked from branch <em>master</em>,
Junio C Hamanod8c9d432006-11-07 07:19:13408for example because the functionality <em>topic</em> branch depend on
Junio C Hamanoba4b9282008-07-06 05:20:31409got merged into more stable <em>master</em> branch, like this:</p></div>
Junio C Hamanod8c9d432006-11-07 07:19:13410<div class="listingblock">
411<div class="content">
412<pre><tt> o---o---o---o---o master
413 | \
414 | o'--o'--o' topic
415 \
416 o---o---o---o---o next</tt></pre>
417</div></div>
Junio C Hamanoba4b9282008-07-06 05:20:31418<div class="para"><p>We can get this using the following command:</p></div>
Junio C Hamanod8c9d432006-11-07 07:19:13419<div class="literalblock">
420<div class="content">
Junio C Hamanofce7c7e2008-07-02 03:06:38421<pre><tt>git rebase --onto master next topic</tt></pre>
Junio C Hamanod8c9d432006-11-07 07:19:13422</div></div>
Junio C Hamanoba4b9282008-07-06 05:20:31423<div class="para"><p>Another example of --onto option is to rebase part of a
424branch. If we have the following situation:</p></div>
Junio C Hamanod8c9d432006-11-07 07:19:13425<div class="listingblock">
426<div class="content">
427<pre><tt> H---I---J topicB
428 /
429 E---F---G topicA
430 /
431 A---B---C---D master</tt></pre>
432</div></div>
Junio C Hamanoba4b9282008-07-06 05:20:31433<div class="para"><p>then the command</p></div>
Junio C Hamanod8c9d432006-11-07 07:19:13434<div class="literalblock">
435<div class="content">
Junio C Hamanofce7c7e2008-07-02 03:06:38436<pre><tt>git rebase --onto master topicA topicB</tt></pre>
Junio C Hamanod8c9d432006-11-07 07:19:13437</div></div>
Junio C Hamanoba4b9282008-07-06 05:20:31438<div class="para"><p>would result in:</p></div>
Junio C Hamanod8c9d432006-11-07 07:19:13439<div class="listingblock">
440<div class="content">
441<pre><tt> H'--I'--J' topicB
442 /
443 | E---F---G topicA
444 |/
445 A---B---C---D master</tt></pre>
446</div></div>
Junio C Hamanoba4b9282008-07-06 05:20:31447<div class="para"><p>This is useful when topicB does not depend on topicA.</p></div>
448<div class="para"><p>A range of commits could also be removed with rebase. If we have
449the following situation:</p></div>
Junio C Hamano42f855f2007-02-06 00:09:38450<div class="listingblock">
451<div class="content">
452<pre><tt> E---F---G---H---I---J topicA</tt></pre>
453</div></div>
Junio C Hamanoba4b9282008-07-06 05:20:31454<div class="para"><p>then the command</p></div>
Junio C Hamano42f855f2007-02-06 00:09:38455<div class="literalblock">
456<div class="content">
Junio C Hamanofce7c7e2008-07-02 03:06:38457<pre><tt>git rebase --onto topicA~5 topicA~3 topicA</tt></pre>
Junio C Hamano42f855f2007-02-06 00:09:38458</div></div>
Junio C Hamanoba4b9282008-07-06 05:20:31459<div class="para"><p>would result in the removal of commits F and G:</p></div>
Junio C Hamano42f855f2007-02-06 00:09:38460<div class="listingblock">
461<div class="content">
462<pre><tt> E---H'---I'---J' topicA</tt></pre>
463</div></div>
Junio C Hamanoba4b9282008-07-06 05:20:31464<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:38465part of topicA. Note that the argument to --onto and the &lt;upstream&gt;
Junio C Hamanoba4b9282008-07-06 05:20:31466parameter can be any valid commit-ish.</p></div>
467<div class="para"><p>In case of conflict, <em>git-rebase</em> will stop at the first problematic commit
468and leave conflict markers in the tree. You can use <em>git-diff</em> to locate
Junio C Hamano6112cad2006-05-02 07:28:06469the markers (&lt;&lt;&lt;&lt;&lt;&lt;) and make edits to resolve the conflict. For each
470file you edit, you need to tell git that the conflict has been resolved,
Junio C Hamanoba4b9282008-07-06 05:20:31471typically this would be done with</p></div>
Junio C Hamanof02e09f2006-03-27 07:51:03472<div class="literalblock">
473<div class="content">
Junio C Hamano89d4e0f2007-02-18 00:34:59474<pre><tt>git add &lt;filename&gt;</tt></pre>
Junio C Hamano6112cad2006-05-02 07:28:06475</div></div>
Junio C Hamanoba4b9282008-07-06 05:20:31476<div class="para"><p>After resolving the conflict manually and updating the index with the
477desired resolution, you can continue the rebasing process with</p></div>
Junio C Hamano6112cad2006-05-02 07:28:06478<div class="literalblock">
479<div class="content">
480<pre><tt>git rebase --continue</tt></pre>
Junio C Hamanof02e09f2006-03-27 07:51:03481</div></div>
Junio C Hamanoba4b9282008-07-06 05:20:31482<div class="para"><p>Alternatively, you can undo the <em>git-rebase</em> with</p></div>
Junio C Hamanof02e09f2006-03-27 07:51:03483<div class="literalblock">
484<div class="content">
Junio C Hamano6112cad2006-05-02 07:28:06485<pre><tt>git rebase --abort</tt></pre>
Junio C Hamanof02e09f2006-03-27 07:51:03486</div></div>
Junio C Hamano1a4e8412005-12-27 08:17:23487</div>
Junio C Hamanoba4b9282008-07-06 05:20:31488<h2 id="_options">OPTIONS</h2>
Junio C Hamano1a4e8412005-12-27 08:17:23489<div class="sectionbody">
Junio C Hamanoba4b9282008-07-06 05:20:31490<div class="vlist"><dl>
Junio C Hamano1a4e8412005-12-27 08:17:23491<dt>
Junio C Hamano7e9f6b72006-02-22 10:44:55492&lt;newbase&gt;
493</dt>
494<dd>
495<p>
496 Starting point at which to create the new commits. If the
497 --onto option is not specified, the starting point is
Junio C Hamano42f855f2007-02-06 00:09:38498 &lt;upstream&gt;. May be any valid commit, and not just an
499 existing branch name.
Junio C Hamano7e9f6b72006-02-22 10:44:55500</p>
501</dd>
502<dt>
Junio C Hamano1a4e8412005-12-27 08:17:23503&lt;upstream&gt;
504</dt>
505<dd>
506<p>
Junio C Hamano42f855f2007-02-06 00:09:38507 Upstream branch to compare against. May be any valid commit,
508 not just an existing branch name.
Junio C Hamano1a4e8412005-12-27 08:17:23509</p>
510</dd>
511<dt>
Junio C Hamano2b135272006-03-18 07:45:42512&lt;branch&gt;
Junio C Hamano1a4e8412005-12-27 08:17:23513</dt>
514<dd>
515<p>
516 Working branch; defaults to HEAD.
517</p>
518</dd>
Junio C Hamano6112cad2006-05-02 07:28:06519<dt>
520--continue
521</dt>
522<dd>
523<p>
524 Restart the rebasing process after having resolved a merge conflict.
525</p>
526</dd>
527<dt>
528--abort
529</dt>
530<dd>
531<p>
532 Restore the original branch and abort the rebase operation.
533</p>
534</dd>
Junio C Hamano97f518c2006-06-22 19:49:35535<dt>
536--skip
537</dt>
538<dd>
539<p>
540 Restart the rebasing process by skipping the current patch.
Junio C Hamano97f518c2006-06-22 19:49:35541</p>
542</dd>
543<dt>
Junio C Hamanoeb415992008-06-08 22:49:47544-m
545</dt>
546<dt>
547--merge
Junio C Hamano97f518c2006-06-22 19:49:35548</dt>
549<dd>
550<p>
551 Use merging strategies to rebase. When the recursive (default) merge
552 strategy is used, this allows rebase to be aware of renames on the
553 upstream side.
554</p>
555</dd>
556<dt>
Junio C Hamanoeb415992008-06-08 22:49:47557-s &lt;strategy&gt;
558</dt>
559<dt>
560--strategy=&lt;strategy&gt;
Junio C Hamano97f518c2006-06-22 19:49:35561</dt>
562<dd>
563<p>
564 Use the given merge strategy; can be supplied more than
565 once to specify them in the order they should be tried.
566 If there is no <tt>-s</tt> option, a built-in list of strategies
Junio C Hamanoba4b9282008-07-06 05:20:31567 is used instead (<em>git-merge-recursive</em> when merging a single
568 head, <em>git-merge-octopus</em> otherwise). This implies --merge.
Junio C Hamano97f518c2006-06-22 19:49:35569</p>
570</dd>
Junio C Hamanofbe00522006-10-19 05:58:48571<dt>
Junio C Hamanoeb415992008-06-08 22:49:47572-v
573</dt>
574<dt>
575--verbose
Junio C Hamanofbe00522006-10-19 05:58:48576</dt>
577<dd>
578<p>
579 Display a diffstat of what changed upstream since the last rebase.
580</p>
581</dd>
Junio C Hamanod3339982007-02-09 08:38:48582<dt>
583-C&lt;n&gt;
584</dt>
585<dd>
586<p>
587 Ensure at least &lt;n&gt; lines of surrounding context match before
588 and after each change. When fewer lines of surrounding
589 context exist they all must match. By default no context is
590 ever ignored.
591</p>
592</dd>
Junio C Hamano1d90cb02007-07-03 07:05:31593<dt>
Junio C Hamano250f03e2007-09-10 01:33:28594--whitespace=&lt;nowarn|warn|error|error-all|strip&gt;
595</dt>
596<dd>
597<p>
Junio C Hamanoba4b9282008-07-06 05:20:31598 This flag is passed to the <em>git-apply</em> program
Junio C Hamano250f03e2007-09-10 01:33:28599 (see <a href="git-apply.html">git-apply(1)</a>) that applies the patch.
600</p>
601</dd>
602<dt>
Junio C Hamanoeb415992008-06-08 22:49:47603-i
604</dt>
605<dt>
606--interactive
Junio C Hamano1d90cb02007-07-03 07:05:31607</dt>
608<dd>
609<p>
610 Make a list of the commits which are about to be rebased. Let the
Junio C Hamanodbb64592007-09-01 11:17:39611 user edit that list before rebasing. This mode can also be used to
612 split commits (see SPLITTING COMMITS below).
Junio C Hamano1d90cb02007-07-03 07:05:31613</p>
614</dd>
615<dt>
Junio C Hamanoeb415992008-06-08 22:49:47616-p
617</dt>
618<dt>
619--preserve-merges
Junio C Hamano1d90cb02007-07-03 07:05:31620</dt>
621<dd>
622<p>
623 Instead of ignoring merges, try to recreate them. This option
624 only works in interactive mode.
625</p>
626</dd>
Junio C Hamanoba4b9282008-07-06 05:20:31627</dl></div>
Junio C Hamano97f518c2006-06-22 19:49:35628</div>
Junio C Hamanoba4b9282008-07-06 05:20:31629<h2 id="_merge_strategies">MERGE STRATEGIES</h2>
Junio C Hamano97f518c2006-06-22 19:49:35630<div class="sectionbody">
Junio C Hamanoba4b9282008-07-06 05:20:31631<div class="vlist"><dl>
Junio C Hamano97f518c2006-06-22 19:49:35632<dt>
633resolve
634</dt>
635<dd>
636<p>
637 This can only resolve two heads (i.e. the current branch
638 and another branch you pulled from) using 3-way merge
639 algorithm. It tries to carefully detect criss-cross
640 merge ambiguities and is considered generally safe and
641 fast.
642</p>
643</dd>
644<dt>
645recursive
646</dt>
647<dd>
648<p>
649 This can only resolve two heads using 3-way merge
650 algorithm. When there are more than one common
651 ancestors that can be used for 3-way merge, it creates a
652 merged tree of the common ancestors and uses that as
653 the reference tree for the 3-way merge. This has been
654 reported to result in fewer merge conflicts without
655 causing mis-merges by tests done on actual merge commits
656 taken from Linux 2.6 kernel development history.
657 Additionally this can detect and handle merges involving
658 renames. This is the default merge strategy when
659 pulling or merging one branch.
660</p>
661</dd>
662<dt>
663octopus
664</dt>
665<dd>
666<p>
667 This resolves more than two-head case, but refuses to do
668 complex merge that needs manual resolution. It is
669 primarily meant to be used for bundling topic branch
670 heads together. This is the default merge strategy when
671 pulling or merging more than one branches.
672</p>
673</dd>
674<dt>
675ours
676</dt>
677<dd>
678<p>
679 This resolves any number of heads, but the result of the
680 merge is always the current branch head. It is meant to
681 be used to supersede old development history of side
682 branches.
683</p>
684</dd>
Junio C Hamanoe6c92032008-03-19 09:24:34685<dt>
686subtree
687</dt>
688<dd>
689<p>
690 This is a modified recursive strategy. When merging trees A and
691 B, if B corresponds to a subtree of A, B is first adjusted to
692 match the tree structure of A, instead of reading the trees at
693 the same level. This adjustment is also done to the common
694 ancestor tree.
695</p>
696</dd>
Junio C Hamanoba4b9282008-07-06 05:20:31697</dl></div>
Junio C Hamano1a4e8412005-12-27 08:17:23698</div>
Junio C Hamanoba4b9282008-07-06 05:20:31699<h2 id="_notes">NOTES</h2>
Junio C Hamano6112cad2006-05-02 07:28:06700<div class="sectionbody">
Junio C Hamanoba4b9282008-07-06 05:20:31701<div class="para"><p>When you rebase a branch, you are changing its history in a way that
Junio C Hamano6112cad2006-05-02 07:28:06702will cause problems for anyone who already has a copy of the branch
703in their repository and tries to pull updates from you. You should
Junio C Hamanoba4b9282008-07-06 05:20:31704understand the implications of using <em>git-rebase</em> on a repository that
705you share.</p></div>
706<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:06707hook if one exists. You can use this hook to do sanity checks and
708reject the rebase if it isn't appropriate. Please see the template
Junio C Hamanoba4b9282008-07-06 05:20:31709pre-rebase hook script for an example.</p></div>
710<div class="para"><p>Upon completion, &lt;branch&gt; will be the current branch.</p></div>
Junio C Hamano6112cad2006-05-02 07:28:06711</div>
Junio C Hamanoba4b9282008-07-06 05:20:31712<h2 id="_interactive_mode">INTERACTIVE MODE</h2>
Junio C Hamano1a4e8412005-12-27 08:17:23713<div class="sectionbody">
Junio C Hamanoba4b9282008-07-06 05:20:31714<div class="para"><p>Rebasing interactively means that you have a chance to edit the commits
Junio C Hamano1d90cb02007-07-03 07:05:31715which are rebased. You can reorder the commits, and you can
Junio C Hamanoba4b9282008-07-06 05:20:31716remove them (weeding out bad or otherwise unwanted patches).</p></div>
717<div class="para"><p>The interactive mode is meant for this type of workflow:</p></div>
718<div class="olist"><ol>
Junio C Hamano1d90cb02007-07-03 07:05:31719<li>
720<p>
721have a wonderful idea
722</p>
723</li>
724<li>
725<p>
726hack on the code
727</p>
728</li>
729<li>
730<p>
731prepare a series for submission
732</p>
733</li>
734<li>
735<p>
736submit
737</p>
738</li>
Junio C Hamanoba4b9282008-07-06 05:20:31739</ol></div>
740<div class="para"><p>where point 2. consists of several instances of</p></div>
741<div class="olist2"><ol>
Junio C Hamano1d90cb02007-07-03 07:05:31742<li>
743<p>
744regular use
745</p>
Junio C Hamanoba4b9282008-07-06 05:20:31746<div class="olist"><ol>
Junio C Hamano1d90cb02007-07-03 07:05:31747<li>
748<p>
749finish something worthy of a commit
750</p>
751</li>
752<li>
753<p>
754commit
755</p>
756</li>
Junio C Hamanoba4b9282008-07-06 05:20:31757</ol></div>
Junio C Hamano1d90cb02007-07-03 07:05:31758</li>
759<li>
760<p>
761independent fixup
762</p>
Junio C Hamanoba4b9282008-07-06 05:20:31763<div class="olist"><ol>
Junio C Hamano1d90cb02007-07-03 07:05:31764<li>
765<p>
766realize that something does not work
767</p>
768</li>
769<li>
770<p>
771fix that
772</p>
773</li>
774<li>
775<p>
776commit it
777</p>
778</li>
Junio C Hamanoba4b9282008-07-06 05:20:31779</ol></div>
Junio C Hamano1d90cb02007-07-03 07:05:31780</li>
Junio C Hamanoba4b9282008-07-06 05:20:31781</ol></div>
782<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:31783perfect commit it fixes, because that commit is buried deeply in a
784patch series. That is exactly what interactive rebase is for: use it
785after plenty of "a"s and "b"s, by rearranging and editing
Junio C Hamanoba4b9282008-07-06 05:20:31786commits, and squashing multiple commits into one.</p></div>
787<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:31788<div class="literalblock">
789<div class="content">
790<pre><tt>git rebase -i &lt;after-this-commit&gt;</tt></pre>
791</div></div>
Junio C Hamanoba4b9282008-07-06 05:20:31792<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:31793(ignoring merge commits), which come after the given commit. You can
794reorder the commits in this list to your heart's content, and you can
Junio C Hamanoba4b9282008-07-06 05:20:31795remove them. The list looks more or less like this:</p></div>
Junio C Hamano1d90cb02007-07-03 07:05:31796<div class="listingblock">
797<div class="content">
798<pre><tt>pick deadbee The oneline of this commit
799pick fa1afe1 The oneline of the next commit
800...</tt></pre>
801</div></div>
Junio C Hamanoba4b9282008-07-06 05:20:31802<div class="para"><p>The oneline descriptions are purely for your pleasure; <em>git-rebase</em> will
Junio C Hamano1d90cb02007-07-03 07:05:31803not look at them but at the commit names ("deadbee" and "fa1afe1" in this
Junio C Hamanoba4b9282008-07-06 05:20:31804example), so do not delete or edit the names.</p></div>
805<div class="para"><p>By replacing the command "pick" with the command "edit", you can tell
806<em>git-rebase</em> to stop after applying that commit, so that you can edit
Junio C Hamano1d90cb02007-07-03 07:05:31807the files and/or the commit message, amend the commit, and continue
Junio C Hamanoba4b9282008-07-06 05:20:31808rebasing.</p></div>
809<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:31810"pick" with "squash" for the second and subsequent commit. If the
811commits had different authors, it will attribute the squashed commit to
Junio C Hamanoba4b9282008-07-06 05:20:31812the author of the first commit.</p></div>
813<div class="para"><p>In both cases, or when a "pick" does not succeed (because of merge
Junio C Hamano1d90cb02007-07-03 07:05:31814errors), the loop will stop to let you fix things, and you can continue
Junio C Hamanoba4b9282008-07-06 05:20:31815the loop with <tt>git rebase --continue</tt>.</p></div>
816<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:31817was HEAD~4 becomes the new HEAD. To achieve that, you would call
Junio C Hamanoba4b9282008-07-06 05:20:31818<em>git-rebase</em> like this:</p></div>
Junio C Hamano1d90cb02007-07-03 07:05:31819<div class="listingblock">
820<div class="content">
821<pre><tt>$ git rebase -i HEAD~5</tt></pre>
822</div></div>
Junio C Hamanoba4b9282008-07-06 05:20:31823<div class="para"><p>And move the first patch to the end of the list.</p></div>
824<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:31825<div class="listingblock">
826<div class="content">
827<pre><tt> X
828 \
829 A---M---B
830 /
831---o---O---P---Q</tt></pre>
832</div></div>
Junio C Hamanoba4b9282008-07-06 05:20:31833<div class="para"><p>Suppose you want to rebase the side branch starting at "A" to "Q". Make
834sure that the current HEAD is "B", and call</p></div>
Junio C Hamano1d90cb02007-07-03 07:05:31835<div class="listingblock">
836<div class="content">
837<pre><tt>$ git rebase -i -p --onto Q O</tt></pre>
838</div></div>
839</div>
Junio C Hamanoba4b9282008-07-06 05:20:31840<h2 id="_splitting_commits">SPLITTING COMMITS</h2>
Junio C Hamanodbb64592007-09-01 11:17:39841<div class="sectionbody">
Junio C Hamanoba4b9282008-07-06 05:20:31842<div class="para"><p>In interactive mode, you can mark commits with the action "edit". However,
843this does not necessarily mean that <em>git-rebase</em> expects the result of this
Junio C Hamanodbb64592007-09-01 11:17:39844edit to be exactly one commit. Indeed, you can undo the commit, or you can
Junio C Hamanoba4b9282008-07-06 05:20:31845add other commits. This can be used to split a commit into two:</p></div>
846<div class="ilist"><ul>
Junio C Hamanodbb64592007-09-01 11:17:39847<li>
848<p>
Junio C Hamanofce7c7e2008-07-02 03:06:38849Start an interactive rebase with <tt>git rebase -i &lt;commit&gt;^</tt>, where
Junio C Hamanodbb64592007-09-01 11:17:39850 &lt;commit&gt; is the commit you want to split. In fact, any commit range
851 will do, as long as it contains that commit.
852</p>
853</li>
854<li>
855<p>
856Mark the commit you want to split with the action "edit".
857</p>
858</li>
859<li>
860<p>
Junio C Hamanofce7c7e2008-07-02 03:06:38861When it comes to editing that commit, execute <tt>git reset HEAD^</tt>. The
Junio C Hamanodbb64592007-09-01 11:17:39862 effect is that the HEAD is rewound by one, and the index follows suit.
863 However, the working tree stays the same.
864</p>
865</li>
866<li>
867<p>
868Now add the changes to the index that you want to have in the first
Junio C Hamanofce7c7e2008-07-02 03:06:38869 commit. You can use <tt>git add</tt> (possibly interactively) or
Junio C Hamanoba4b9282008-07-06 05:20:31870 <em>git-gui</em> (or both) to do that.
Junio C Hamanodbb64592007-09-01 11:17:39871</p>
872</li>
873<li>
874<p>
875Commit the now-current index with whatever commit message is appropriate
876 now.
877</p>
878</li>
879<li>
880<p>
881Repeat the last two steps until your working tree is clean.
882</p>
883</li>
884<li>
885<p>
Junio C Hamanofce7c7e2008-07-02 03:06:38886Continue the rebase with <tt>git rebase --continue</tt>.
Junio C Hamanodbb64592007-09-01 11:17:39887</p>
888</li>
Junio C Hamanoba4b9282008-07-06 05:20:31889</ul></div>
890<div class="para"><p>If you are not absolutely sure that the intermediate revisions are
Junio C Hamanodbb64592007-09-01 11:17:39891consistent (they compile, pass the testsuite, etc.) you should use
Junio C Hamanoba4b9282008-07-06 05:20:31892<em>git-stash</em> to stash away the not-yet-committed changes
893after each commit, test, and amend the commit if fixes are necessary.</p></div>
Junio C Hamanodbb64592007-09-01 11:17:39894</div>
Junio C Hamanoba4b9282008-07-06 05:20:31895<h2 id="_authors">Authors</h2>
Junio C Hamano1d90cb02007-07-03 07:05:31896<div class="sectionbody">
Junio C Hamano0868a302008-07-22 09:20:44897<div class="para"><p>Written by Junio C Hamano &lt;gitster@pobox.com&gt; and
Junio C Hamanoba4b9282008-07-06 05:20:31898Johannes E. Schindelin &lt;johannes.schindelin@gmx.de&gt;</p></div>
Junio C Hamano1a4e8412005-12-27 08:17:23899</div>
Junio C Hamanoba4b9282008-07-06 05:20:31900<h2 id="_documentation">Documentation</h2>
Junio C Hamano1a4e8412005-12-27 08:17:23901<div class="sectionbody">
Junio C Hamanoba4b9282008-07-06 05:20:31902<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:23903</div>
Junio C Hamanoba4b9282008-07-06 05:20:31904<h2 id="_git">GIT</h2>
Junio C Hamano1a4e8412005-12-27 08:17:23905<div class="sectionbody">
Junio C Hamanoba4b9282008-07-06 05:20:31906<div class="para"><p>Part of the <a href="git.html">git(1)</a> suite</p></div>
Junio C Hamano1a4e8412005-12-27 08:17:23907</div>
908<div id="footer">
909<div id="footer-text">
Junio C Hamano0868a302008-07-22 09:20:44910Last updated 2008-07-22 09:19:14 UTC
Junio C Hamano1a4e8412005-12-27 08:17:23911</div>
912</div>
913</body>
914</html>