@@ -8,7 +8,8 @@ git-rebase - Forward-port local commits to the updated upstream head
8
8
SYNOPSIS
9
9
--------
10
10
[verse]
11
- 'git-rebase' [-v] [--merge] [-C<n>] [--onto <newbase>] <upstream> [<branch>]
11
+ 'git-rebase' [-i | --interactive] [-v | --verbose] [--merge] [-C<n>]
12
+ [-p | --preserve-merges] [--onto <newbase>] <upstream> [<branch>]
12
13
'git-rebase' --continue | --skip | --abort
13
14
14
15
DESCRIPTION
@@ -208,6 +209,14 @@ OPTIONS
208
209
context exist they all must match. By default no context is
209
210
ever ignored.
210
211
212
+ -i, \--interactive::
213
+ Make a list of the commits which are about to be rebased. Let the
214
+ user edit that list before rebasing.
215
+
216
+ -p, \--preserve-merges::
217
+ Instead of ignoring merges, try to recreate them. This option
218
+ only works in interactive mode.
219
+
211
220
include::merge-strategies.txt[]
212
221
213
222
NOTES
@@ -226,9 +235,100 @@ pre-rebase hook script for an example.
226
235
You must be in the top directory of your project to start (or continue)
227
236
a rebase. Upon completion, <branch> will be the current branch.
228
237
229
- Author
238
+ INTERACTIVE MODE
239
+ ----------------
240
+
241
+ Rebasing interactively means that you have a chance to edit the commits
242
+ which are rebased. You can reorder the commits, and you can
243
+ remove them (weeding out bad or otherwise unwanted patches).
244
+
245
+ The interactive mode is meant for this type of workflow:
246
+
247
+ 1. have a wonderful idea
248
+ 2. hack on the code
249
+ 3. prepare a series for submission
250
+ 4. submit
251
+
252
+ where point 2. consists of several instances of
253
+
254
+ a. regular use
255
+ 1. finish something worthy of a commit
256
+ 2. commit
257
+ b. independent fixup
258
+ 1. realize that something does not work
259
+ 2. fix that
260
+ 3. commit it
261
+
262
+ Sometimes the thing fixed in b.2. cannot be amended to the not-quite
263
+ perfect commit it fixes, because that commit is buried deeply in a
264
+ patch series. That is exactly what interactive rebase is for: use it
265
+ after plenty of "a"s and "b"s, by rearranging and editing
266
+ commits, and squashing multiple commits into one.
267
+
268
+ Start it with the last commit you want to retain as-is:
269
+
270
+ git rebase -i <after-this-commit>
271
+
272
+ An editor will be fired up with all the commits in your current branch
273
+ (ignoring merge commits), which come after the given commit. You can
274
+ reorder the commits in this list to your heart's content, and you can
275
+ remove them. The list looks more or less like this:
276
+
277
+ -------------------------------------------
278
+ pick deadbee The oneline of this commit
279
+ pick fa1afe1 The oneline of the next commit
280
+ ...
281
+ -------------------------------------------
282
+
283
+ The oneline descriptions are purely for your pleasure; `git-rebase` will
284
+ not look at them but at the commit names ("deadbee" and "fa1afe1" in this
285
+ example), so do not delete or edit the names.
286
+
287
+ By replacing the command "pick" with the command "edit", you can tell
288
+ `git-rebase` to stop after applying that commit, so that you can edit
289
+ the files and/or the commit message, amend the commit, and continue
290
+ rebasing.
291
+
292
+ If you want to fold two or more commits into one, replace the command
293
+ "pick" with "squash" for the second and subsequent commit. If the
294
+ commits had different authors, it will attribute the squashed commit to
295
+ the author of the last commit.
296
+
297
+ In both cases, or when a "pick" does not succeed (because of merge
298
+ errors), the loop will stop to let you fix things, and you can continue
299
+ the loop with `git rebase --continue`.
300
+
301
+ For example, if you want to reorder the last 5 commits, such that what
302
+ was HEAD~4 becomes the new HEAD. To achieve that, you would call
303
+ `git-rebase` like this:
304
+
305
+ ----------------------
306
+ $ git rebase -i HEAD~5
307
+ ----------------------
308
+
309
+ And move the first patch to the end of the list.
310
+
311
+ You might want to preserve merges, if you have a history like this:
312
+
313
+ ------------------
314
+ X
315
+ \
316
+ A---M---B
317
+ /
318
+ ---o---O---P---Q
319
+ ------------------
320
+
321
+ Suppose you want to rebase the side branch starting at "A" to "Q". Make
322
+ sure that the current HEAD is "B", and call
323
+
324
+ -----------------------------
325
+ $ git rebase -i -p --onto Q O
326
+ -----------------------------
327
+
328
+ Authors
230
329
------
231
- Written by Junio C Hamano <
[email protected] >
330
+ Written by Junio C Hamano <
[email protected] > and
331
+ Johannes E. Schindelin <
[email protected] >
232
332
233
333
Documentation
234
334
--------------
0 commit comments