Skip to content

Commit e7a8fbb

Browse files
committed
doc: git-rebase: start with an example
- Start with an example that mirrors the example in the `git-merge` man page, to make it easier for folks to understand the difference between a rebase and a merge. - Mention that rebase can combine or reorder commits Signed-off-by: Julia Evans <[email protected]>
1 parent 2c2ba49 commit e7a8fbb

File tree

1 file changed

+26
-26
lines changed

1 file changed

+26
-26
lines changed

Documentation/git-rebase.adoc

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,32 @@ SYNOPSIS
1616

1717
DESCRIPTION
1818
-----------
19+
Transplant a series of commits onto a different starting point.
20+
You can also use `git rebase` to reorder or combine commits: see INTERACTIVE
21+
MODE below for how to do that.
22+
23+
For example, imagine that you have been working on the `topic` branch in this
24+
history, and you want to "catch up" to the work done on the `master` branch.
25+
26+
------------
27+
A---B---C topic
28+
/
29+
D---E---F---G master
30+
------------
31+
32+
You want to transplant the commits you made on `topic` since it diverged from
33+
`master` (i.e. A, B, and C), on top of the current `master`. You can do this
34+
by running `git rebase master` while the `topic` branch is checked out. If you
35+
want to rebase `topic` while on another branch, `git rebase master topic` is a
36+
shortcut for `git checkout topic && git rebase master`.
37+
38+
------------
39+
A'--B'--C' topic
40+
/
41+
D---E---F---G master
42+
------------
43+
44+
1945
If `<branch>` is specified, `git rebase` will perform an automatic
2046
`git switch <branch>` before doing anything else. Otherwise
2147
it remains on the current branch.
@@ -58,32 +84,6 @@ that caused the merge failure with `git rebase --skip`. To check out the
5884
original `<branch>` and remove the `.git/rebase-apply` working files, use
5985
the command `git rebase --abort` instead.
6086

61-
Assume the following history exists and the current branch is "topic":
62-
63-
------------
64-
A---B---C topic
65-
/
66-
D---E---F---G master
67-
------------
68-
69-
From this point, the result of either of the following commands:
70-
71-
72-
git rebase master
73-
git rebase master topic
74-
75-
would be:
76-
77-
------------
78-
A'--B'--C' topic
79-
/
80-
D---E---F---G master
81-
------------
82-
83-
*NOTE:* The latter form is just a short-hand of `git checkout topic`
84-
followed by `git rebase master`. When rebase exits `topic` will
85-
remain the checked-out branch.
86-
8787
If the upstream branch already contains a change you have made (e.g.,
8888
because you mailed a patch which was applied upstream), then that commit
8989
will be skipped and warnings will be issued (if the 'merge' backend is

0 commit comments

Comments
 (0)