Skip to content

Commit 0a3c2b2

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. Signed-off-by: Julia Evans <[email protected]>
1 parent 2c2ba49 commit 0a3c2b2

File tree

1 file changed

+23
-26
lines changed

1 file changed

+23
-26
lines changed

Documentation/git-rebase.adoc

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

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

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-
8784
If the upstream branch already contains a change you have made (e.g.,
8885
because you mailed a patch which was applied upstream), then that commit
8986
will be skipped and warnings will be issued (if the 'merge' backend is

0 commit comments

Comments
 (0)