rebase -i: mention the option to split commits in the man page
The interactive mode of rebase can be used to split commits. Tell the interested parties about it, with a dedicated section in the man page. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Johannes Schindelin committed
Aug 31, 2007 at 18:10 UTC
f0fd889d7ff02efe8ee4a25ae2380db47c128682
1 file changed
+38
-1
Documentation/git-rebase.txt
+38
-1
@@ -211,7 +211,8 @@ OPTIONS
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.
214
+ user edit that list before rebasing. This mode can also be used to
215
+ split commits (see SPLITTING COMMITS below).
216
217
-p, \--preserve-merges::
218
Instead of ignoring merges, try to recreate them. This option
@@ -325,6 +326,42 @@ sure that the current HEAD is "B", and call
326
$ git rebase -i -p --onto Q O
327
-----------------------------
328
329
+
330
+SPLITTING COMMITS
331
+-----------------
332
+
333
+In interactive mode, you can mark commits with the action "edit". However,
334
+this does not necessarily mean that 'git rebase' expects the result of this
335
+edit to be exactly one commit. Indeed, you can undo the commit, or you can
336
+add other commits. This can be used to split a commit into two:
337
+
338
+- Start an interactive rebase with 'git rebase -i <commit>^', where
339
+ <commit> is the commit you want to split. In fact, any commit range
340
+ will do, as long as it contains that commit.
341
+
342
+- Mark the commit you want to split with the action "edit".
343
+
344
+- When it comes to editing that commit, execute 'git reset HEAD^'. The
345
+ effect is that the HEAD is rewound by one, and the index follows suit.
346
+ However, the working tree stays the same.
347
+
348
+- Now add the changes to the index that you want to have in the first
349
+ commit. You can use gitlink:git-add[1] (possibly interactively) and/or
350
+ gitlink:git-gui[1] to do that.
351
+
352
+- Commit the now-current index with whatever commit message is appropriate
353
+ now.
354
+
355
+- Repeat the last two steps until your working tree is clean.
356
+
357
+- Continue the rebase with 'git rebase --continue'.
358
+
359
+If you are not absolutely sure that the intermediate revisions are
360
+consistent (they compile, pass the testsuite, etc.) you should use
361
+gitlink:git-stash[1] to stash away the not-yet-committed changes
362
+after each commit, test, and amend the commit if fixes are necessary.
363
+
364
+
365
Authors
366
------
367
Written by Junio C Hamano <junkio@cox.net> and