blob: d10a5a0adc2d39010b7acf87a2857a99cf97a339 [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 Hamano7e9f6b72006-02-22 10:44:556<meta name="generator" content="AsciiDoc 7.0.2" />
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
19a { color: blue; }
20a:visited { color: fuchsia; }
21
22em {
23 font-style: italic;
24}
25
26strong {
27 font-weight: bold;
28}
29
30tt {
31 color: navy;
32}
33
34h1, h2, h3, h4, h5, h6 {
35 color: #527bbd;
36 font-family: sans-serif;
37 margin-top: 1.2em;
38 margin-bottom: 0.5em;
39 line-height: 1.3;
40}
41
42h1 {
43 border-bottom: 2px solid silver;
44}
45h2 {
46 border-bottom: 2px solid silver;
47 padding-top: 0.5em;
48}
49
50div.sectionbody {
51 font-family: serif;
52 margin-left: 0;
53}
54
55hr {
56 border: 1px solid silver;
57}
58
59p {
60 margin-top: 0.5em;
61 margin-bottom: 0.5em;
62}
63
64pre {
65 padding: 0;
66 margin: 0;
67}
68
69span#author {
70 color: #527bbd;
71 font-family: sans-serif;
72 font-weight: bold;
73 font-size: 1.2em;
74}
75span#email {
76}
77span#revision {
78 font-family: sans-serif;
79}
80
81div#footer {
82 font-family: sans-serif;
83 font-size: small;
84 border-top: 2px solid silver;
85 padding-top: 0.5em;
86 margin-top: 4.0em;
87}
88div#footer-text {
89 float: left;
90 padding-bottom: 0.5em;
91}
92div#footer-badges {
93 float: right;
94 padding-bottom: 0.5em;
95}
96
97div#preamble,
98div.tableblock, div.imageblock, div.exampleblock, div.verseblock,
99div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock,
100div.admonitionblock {
101 margin-right: 10%;
102 margin-top: 1.5em;
103 margin-bottom: 1.5em;
104}
105div.admonitionblock {
106 margin-top: 2.5em;
107 margin-bottom: 2.5em;
108}
109
110div.content { /* Block element content. */
111 padding: 0;
112}
113
114/* Block element titles. */
115div.title, caption.title {
116 font-family: sans-serif;
117 font-weight: bold;
118 text-align: left;
119 margin-top: 1.0em;
120 margin-bottom: 0.5em;
121}
122div.title + * {
123 margin-top: 0;
124}
125
126td div.title:first-child {
127 margin-top: 0.0em;
128}
129div.content div.title:first-child {
130 margin-top: 0.0em;
131}
132div.content + div.title {
133 margin-top: 0.0em;
134}
135
136div.sidebarblock > div.content {
137 background: #ffffee;
138 border: 1px solid silver;
139 padding: 0.5em;
140}
141
142div.listingblock > div.content {
143 border: 1px solid silver;
144 background: #f4f4f4;
145 padding: 0.5em;
146}
147
148div.quoteblock > div.content {
149 padding-left: 2.0em;
150}
151div.quoteblock .attribution {
152 text-align: right;
153}
154
155div.admonitionblock .icon {
156 vertical-align: top;
157 font-size: 1.1em;
158 font-weight: bold;
159 text-decoration: underline;
160 color: #527bbd;
161 padding-right: 0.5em;
162}
163div.admonitionblock td.content {
164 padding-left: 0.5em;
165 border-left: 2px solid silver;
166}
167
168div.exampleblock > div.content {
169 border-left: 2px solid silver;
170 padding: 0.5em;
171}
172
173div.verseblock div.content {
174 white-space: pre;
175}
176
177div.imageblock div.content { padding-left: 0; }
178div.imageblock img { border: 1px solid silver; }
179span.image img { border-style: none; }
180
181dl {
182 margin-top: 0.8em;
183 margin-bottom: 0.8em;
184}
185dt {
186 margin-top: 0.5em;
187 margin-bottom: 0;
188 font-style: italic;
189}
190dd > *:first-child {
191 margin-top: 0;
192}
193
194ul, ol {
195 list-style-position: outside;
196}
197ol.olist2 {
198 list-style-type: lower-alpha;
199}
200
201div.tableblock > table {
202 border-color: #527bbd;
203 border-width: 3px;
204}
205thead {
206 font-family: sans-serif;
207 font-weight: bold;
208}
209tfoot {
210 font-weight: bold;
211}
212
213div.hlist {
214 margin-top: 0.8em;
215 margin-bottom: 0.8em;
216}
217td.hlist1 {
218 vertical-align: top;
219 font-style: italic;
220 padding-right: 0.8em;
221}
222td.hlist2 {
223 vertical-align: top;
224}
225
226@media print {
227 div#footer-badges { display: none; }
228}
229include::./stylesheets/xhtml11-manpage.css[]
230/* Workarounds for IE6's broken and incomplete CSS2. */
231
232div.sidebar-content {
233 background: #ffffee;
234 border: 1px solid silver;
235 padding: 0.5em;
236}
237div.sidebar-title, div.image-title {
238 font-family: sans-serif;
239 font-weight: bold;
240 margin-top: 0.0em;
241 margin-bottom: 0.5em;
242}
243
244div.listingblock div.content {
245 border: 1px solid silver;
246 background: #f4f4f4;
247 padding: 0.5em;
248}
249
250div.quoteblock-content {
251 padding-left: 2.0em;
252}
253
254div.exampleblock-content {
255 border-left: 2px solid silver;
256 padding-left: 0.5em;
257}
258</style>
259<title>git-rebase(1)</title>
260</head>
261<body>
262<div id="header">
263<h1>
264git-rebase(1) Manual Page
265</h1>
266<h2>NAME</h2>
267<div class="sectionbody">
268<p>git-rebase -
Junio C Hamano6112cad2006-05-02 07:28:06269 Rebase local commits to a new head
Junio C Hamano1a4e8412005-12-27 08:17:23270</p>
271</div>
272</div>
273<h2>SYNOPSIS</h2>
274<div class="sectionbody">
Junio C Hamanofbe00522006-10-19 05:58:48275<p><em>git-rebase</em> [-v] [--merge] [--onto &lt;newbase&gt;] &lt;upstream&gt; [&lt;branch&gt;]</p>
Junio C Hamano6959c6c2006-05-17 10:34:11276<p><em>git-rebase</em> --continue | --skip | --abort</p>
Junio C Hamano1a4e8412005-12-27 08:17:23277</div>
278<h2>DESCRIPTION</h2>
279<div class="sectionbody">
Junio C Hamano6112cad2006-05-02 07:28:06280<p>git-rebase replaces &lt;branch&gt; with a new branch of the same name. When
281the --onto option is provided the new branch starts out with a HEAD equal
282to &lt;newbase&gt;, otherwise it is equal to &lt;upstream&gt;. It then attempts to
283create a new commit for each commit from the original &lt;branch&gt; that does
284not exist in the &lt;upstream&gt; branch.</p>
285<p>It is possible that a merge failure will prevent this process from being
286completely automatic. You will have to resolve any such merge failure
Junio C Hamano6959c6c2006-05-17 10:34:11287and run <tt>git rebase --continue</tt>. Another option is to bypass the commit
288that caused the merge failure with <tt>git rebase --skip</tt>. To restore the
289original &lt;branch&gt; and remove the .dotest working files, use the command
290<tt>git rebase --abort</tt> instead.</p>
Junio C Hamano6112cad2006-05-02 07:28:06291<p>Note that if &lt;branch&gt; is not specified on the command line, the currently
292checked out branch is used.</p>
Junio C Hamano7e9f6b72006-02-22 10:44:55293<p>Assume the following history exists and the current branch is "topic":</p>
Junio C Hamano6112cad2006-05-02 07:28:06294<div class="listingblock">
Junio C Hamano7e9f6b72006-02-22 10:44:55295<div class="content">
Junio C Hamano6112cad2006-05-02 07:28:06296<pre><tt> A---B---C topic
297 /
298 D---E---F---G master</tt></pre>
Junio C Hamano7e9f6b72006-02-22 10:44:55299</div></div>
Junio C Hamano2b135272006-03-18 07:45:42300<p>From this point, the result of either of the following commands:</p>
Junio C Hamano7e9f6b72006-02-22 10:44:55301<div class="literalblock">
302<div class="content">
303<pre><tt>git-rebase master
304git-rebase master topic</tt></pre>
305</div></div>
306<p>would be:</p>
Junio C Hamano6112cad2006-05-02 07:28:06307<div class="listingblock">
Junio C Hamano7e9f6b72006-02-22 10:44:55308<div class="content">
Junio C Hamano6112cad2006-05-02 07:28:06309<pre><tt> A'--B'--C' topic
310 /
311 D---E---F---G master</tt></pre>
Junio C Hamano7e9f6b72006-02-22 10:44:55312</div></div>
Junio C Hamanod8c9d432006-11-07 07:19:13313<p>The latter form is just a short-hand of <tt>git checkout topic</tt>
314followed by <tt>git rebase master</tt>.</p>
315<p>Here is how you would transplant a topic branch based on one
316branch to another, to pretend that you forked the topic branch
317from the latter branch, using <tt>rebase --onto</tt>.</p>
318<p>First let's assume your <em>topic</em> is based on branch <em>next</em>.
319For example feature developed in <em>topic</em> depends on some
320functionality which is found in <em>next</em>.</p>
Junio C Hamano6112cad2006-05-02 07:28:06321<div class="listingblock">
Junio C Hamano7e9f6b72006-02-22 10:44:55322<div class="content">
Junio C Hamanod8c9d432006-11-07 07:19:13323<pre><tt> o---o---o---o---o master
324 \
325 o---o---o---o---o next
326 \
327 o---o---o topic</tt></pre>
Junio C Hamano7e9f6b72006-02-22 10:44:55328</div></div>
Junio C Hamanod8c9d432006-11-07 07:19:13329<p>We would want to make <em>topic</em> forked from branch <em>master</em>,
330for example because the functionality <em>topic</em> branch depend on
331got merged into more stable <em>master</em> branch, like this:</p>
332<div class="listingblock">
333<div class="content">
334<pre><tt> o---o---o---o---o master
335 | \
336 | o'--o'--o' topic
337 \
338 o---o---o---o---o next</tt></pre>
339</div></div>
340<p>We can get this using the following command:</p>
341<div class="literalblock">
342<div class="content">
343<pre><tt>git-rebase --onto master next topic</tt></pre>
344</div></div>
345<p>Another example of --onto option is to rebase part of a
346branch. If we have the following situation:</p>
347<div class="listingblock">
348<div class="content">
349<pre><tt> H---I---J topicB
350 /
351 E---F---G topicA
352 /
353 A---B---C---D master</tt></pre>
354</div></div>
355<p>then the command</p>
356<div class="literalblock">
357<div class="content">
358<pre><tt>git-rebase --onto master topicA topicB</tt></pre>
359</div></div>
360<p>would result in:</p>
361<div class="listingblock">
362<div class="content">
363<pre><tt> H'--I'--J' topicB
364 /
365 | E---F---G topicA
366 |/
367 A---B---C---D master</tt></pre>
368</div></div>
369<p>This is useful when topicB does not depend on topicA.</p>
Junio C Hamanof02e09f2006-03-27 07:51:03370<p>In case of conflict, git-rebase will stop at the first problematic commit
Junio C Hamano6112cad2006-05-02 07:28:06371and leave conflict markers in the tree. You can use git diff to locate
372the markers (&lt;&lt;&lt;&lt;&lt;&lt;) and make edits to resolve the conflict. For each
373file you edit, you need to tell git that the conflict has been resolved,
374typically this would be done with</p>
Junio C Hamanof02e09f2006-03-27 07:51:03375<div class="literalblock">
376<div class="content">
Junio C Hamano6112cad2006-05-02 07:28:06377<pre><tt>git update-index &lt;filename&gt;</tt></pre>
378</div></div>
379<p>After resolving the conflict manually and updating the index with the
380desired resolution, you can continue the rebasing process with</p>
381<div class="literalblock">
382<div class="content">
383<pre><tt>git rebase --continue</tt></pre>
Junio C Hamanof02e09f2006-03-27 07:51:03384</div></div>
385<p>Alternatively, you can undo the git-rebase with</p>
386<div class="literalblock">
387<div class="content">
Junio C Hamano6112cad2006-05-02 07:28:06388<pre><tt>git rebase --abort</tt></pre>
Junio C Hamanof02e09f2006-03-27 07:51:03389</div></div>
Junio C Hamano1a4e8412005-12-27 08:17:23390</div>
391<h2>OPTIONS</h2>
392<div class="sectionbody">
393<dl>
394<dt>
Junio C Hamano7e9f6b72006-02-22 10:44:55395&lt;newbase&gt;
396</dt>
397<dd>
398<p>
399 Starting point at which to create the new commits. If the
400 --onto option is not specified, the starting point is
401 &lt;upstream&gt;.
402</p>
403</dd>
404<dt>
Junio C Hamano1a4e8412005-12-27 08:17:23405&lt;upstream&gt;
406</dt>
407<dd>
408<p>
409 Upstream branch to compare against.
410</p>
411</dd>
412<dt>
Junio C Hamano2b135272006-03-18 07:45:42413&lt;branch&gt;
Junio C Hamano1a4e8412005-12-27 08:17:23414</dt>
415<dd>
416<p>
417 Working branch; defaults to HEAD.
418</p>
419</dd>
Junio C Hamano6112cad2006-05-02 07:28:06420<dt>
421--continue
422</dt>
423<dd>
424<p>
425 Restart the rebasing process after having resolved a merge conflict.
426</p>
427</dd>
428<dt>
429--abort
430</dt>
431<dd>
432<p>
433 Restore the original branch and abort the rebase operation.
434</p>
435</dd>
Junio C Hamano97f518c2006-06-22 19:49:35436<dt>
437--skip
438</dt>
439<dd>
440<p>
441 Restart the rebasing process by skipping the current patch.
Junio C Hamano97f518c2006-06-22 19:49:35442</p>
443</dd>
444<dt>
445--merge
446</dt>
447<dd>
448<p>
449 Use merging strategies to rebase. When the recursive (default) merge
450 strategy is used, this allows rebase to be aware of renames on the
451 upstream side.
452</p>
453</dd>
454<dt>
455-s &lt;strategy&gt;, --strategy=&lt;strategy&gt;
456</dt>
457<dd>
458<p>
459 Use the given merge strategy; can be supplied more than
460 once to specify them in the order they should be tried.
461 If there is no <tt>-s</tt> option, a built-in list of strategies
462 is used instead (<tt>git-merge-recursive</tt> when merging a single
463 head, <tt>git-merge-octopus</tt> otherwise). This implies --merge.
464</p>
465</dd>
Junio C Hamanofbe00522006-10-19 05:58:48466<dt>
467-v, --verbose
468</dt>
469<dd>
470<p>
471 Display a diffstat of what changed upstream since the last rebase.
472</p>
473</dd>
Junio C Hamano97f518c2006-06-22 19:49:35474</dl>
475</div>
476<h2>MERGE STRATEGIES</h2>
477<div class="sectionbody">
478<dl>
479<dt>
480resolve
481</dt>
482<dd>
483<p>
484 This can only resolve two heads (i.e. the current branch
485 and another branch you pulled from) using 3-way merge
486 algorithm. It tries to carefully detect criss-cross
487 merge ambiguities and is considered generally safe and
488 fast.
489</p>
490</dd>
491<dt>
492recursive
493</dt>
494<dd>
495<p>
496 This can only resolve two heads using 3-way merge
497 algorithm. When there are more than one common
498 ancestors that can be used for 3-way merge, it creates a
499 merged tree of the common ancestors and uses that as
500 the reference tree for the 3-way merge. This has been
501 reported to result in fewer merge conflicts without
502 causing mis-merges by tests done on actual merge commits
503 taken from Linux 2.6 kernel development history.
504 Additionally this can detect and handle merges involving
505 renames. This is the default merge strategy when
506 pulling or merging one branch.
507</p>
508</dd>
509<dt>
510octopus
511</dt>
512<dd>
513<p>
514 This resolves more than two-head case, but refuses to do
515 complex merge that needs manual resolution. It is
516 primarily meant to be used for bundling topic branch
517 heads together. This is the default merge strategy when
518 pulling or merging more than one branches.
519</p>
520</dd>
521<dt>
522ours
523</dt>
524<dd>
525<p>
526 This resolves any number of heads, but the result of the
527 merge is always the current branch head. It is meant to
528 be used to supersede old development history of side
529 branches.
530</p>
531</dd>
Junio C Hamano1a4e8412005-12-27 08:17:23532</dl>
533</div>
Junio C Hamano6112cad2006-05-02 07:28:06534<h2>NOTES</h2>
535<div class="sectionbody">
536<p>When you rebase a branch, you are changing its history in a way that
537will cause problems for anyone who already has a copy of the branch
538in their repository and tries to pull updates from you. You should
539understand the implications of using <em>git rebase</em> on a repository that
540you share.</p>
541<p>When the git rebase command is run, it will first execute a "pre-rebase"
542hook if one exists. You can use this hook to do sanity checks and
543reject the rebase if it isn't appropriate. Please see the template
544pre-rebase hook script for an example.</p>
545<p>You must be in the top directory of your project to start (or continue)
546a rebase. Upon completion, &lt;branch&gt; will be the current branch.</p>
547</div>
Junio C Hamano1a4e8412005-12-27 08:17:23548<h2>Author</h2>
549<div class="sectionbody">
550<p>Written by Junio C Hamano &lt;junkio@cox.net&gt;</p>
551</div>
552<h2>Documentation</h2>
553<div class="sectionbody">
554<p>Documentation by Junio C Hamano and the git-list &lt;git@vger.kernel.org&gt;.</p>
555</div>
556<h2>GIT</h2>
557<div class="sectionbody">
558<p>Part of the <a href="git.html">git(7)</a> suite</p>
559</div>
560<div id="footer">
561<div id="footer-text">
Junio C Hamanod8c9d432006-11-07 07:19:13562Last updated 07-Nov-2006 07:19:02 UTC
Junio C Hamano1a4e8412005-12-27 08:17:23563</div>
564</div>
565</body>
566</html>