Skip to content

Commit 960512a

Browse files
committed
doc: git-rebase: move --onto explanation down
The DESCRIPTION section in `man git-rebase` is extremely long, much longer than in other git man pages. This moves the explanation of how to use `--onto` further down in the man page, with other similar explanations, like "RECOVERING FROM UPSTREAM REBASE" Signed-off-by: Julia Evans <[email protected]>
1 parent b27117e commit 960512a

File tree

1 file changed

+85
-81
lines changed

1 file changed

+85
-81
lines changed

Documentation/git-rebase.adoc

Lines changed: 85 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -113,87 +113,6 @@ will result in:
113113
D---E---A'---F master
114114
------------
115115

116-
Here is how you would transplant a topic branch based on one
117-
branch to another, to pretend that you forked the topic branch
118-
from the latter branch, using `rebase --onto`.
119-
120-
First let's assume your 'topic' is based on branch 'next'.
121-
For example, a feature developed in 'topic' depends on some
122-
functionality which is found in 'next'.
123-
124-
------------
125-
o---o---o---o---o master
126-
\
127-
o---o---o---o---o next
128-
\
129-
o---o---o topic
130-
------------
131-
132-
We want to make 'topic' forked from branch 'master'; for example,
133-
because the functionality on which 'topic' depends was merged into the
134-
more stable 'master' branch. We want our tree to look like this:
135-
136-
------------
137-
o---o---o---o---o master
138-
| \
139-
| o'--o'--o' topic
140-
\
141-
o---o---o---o---o next
142-
------------
143-
144-
We can get this using the following command:
145-
146-
git rebase --onto master next topic
147-
148-
149-
Another example of --onto option is to rebase part of a
150-
branch. If we have the following situation:
151-
152-
------------
153-
H---I---J topicB
154-
/
155-
E---F---G topicA
156-
/
157-
A---B---C---D master
158-
------------
159-
160-
then the command
161-
162-
git rebase --onto master topicA topicB
163-
164-
would result in:
165-
166-
------------
167-
H'--I'--J' topicB
168-
/
169-
| E---F---G topicA
170-
|/
171-
A---B---C---D master
172-
------------
173-
174-
This is useful when topicB does not depend on topicA.
175-
176-
A range of commits could also be removed with rebase. If we have
177-
the following situation:
178-
179-
------------
180-
E---F---G---H---I---J topicA
181-
------------
182-
183-
then the command
184-
185-
git rebase --onto topicA~5 topicA~3 topicA
186-
187-
would result in the removal of commits F and G:
188-
189-
------------
190-
E---H'---I'---J' topicA
191-
------------
192-
193-
This is useful if F and G were flawed in some way, or should not be
194-
part of topicA. Note that the argument to `--onto` and the `<upstream>`
195-
parameter can be any valid commit-ish.
196-
197116
MODE OPTIONS
198117
------------
199118

@@ -1017,6 +936,91 @@ consistent (they compile, pass the testsuite, etc.) you should use
1017936
after each commit, test, and amend the commit if fixes are necessary.
1018937
1019938
939+
TRANSPLANTING A TOPIC BRANCH WITH --onto
940+
----------------------------------------
941+
942+
Here is how you would transplant a topic branch based on one
943+
branch to another, to pretend that you forked the topic branch
944+
from the latter branch, using `rebase --onto`.
945+
946+
First let's assume your 'topic' is based on branch 'next'.
947+
For example, a feature developed in 'topic' depends on some
948+
functionality which is found in 'next'.
949+
950+
------------
951+
o---o---o---o---o master
952+
\
953+
o---o---o---o---o next
954+
\
955+
o---o---o topic
956+
------------
957+
958+
We want to make 'topic' forked from branch 'master'; for example,
959+
because the functionality on which 'topic' depends was merged into the
960+
more stable 'master' branch. We want our tree to look like this:
961+
962+
------------
963+
o---o---o---o---o master
964+
| \
965+
| o'--o'--o' topic
966+
\
967+
o---o---o---o---o next
968+
------------
969+
970+
We can get this using the following command:
971+
972+
git rebase --onto master next topic
973+
974+
975+
Another example of --onto option is to rebase part of a
976+
branch. If we have the following situation:
977+
978+
------------
979+
H---I---J topicB
980+
/
981+
E---F---G topicA
982+
/
983+
A---B---C---D master
984+
------------
985+
986+
then the command
987+
988+
git rebase --onto master topicA topicB
989+
990+
would result in:
991+
992+
------------
993+
H'--I'--J' topicB
994+
/
995+
| E---F---G topicA
996+
|/
997+
A---B---C---D master
998+
------------
999+
1000+
This is useful when topicB does not depend on topicA.
1001+
1002+
A range of commits could also be removed with rebase. If we have
1003+
the following situation:
1004+
1005+
------------
1006+
E---F---G---H---I---J topicA
1007+
------------
1008+
1009+
then the command
1010+
1011+
git rebase --onto topicA~5 topicA~3 topicA
1012+
1013+
would result in the removal of commits F and G:
1014+
1015+
------------
1016+
E---H'---I'---J' topicA
1017+
------------
1018+
1019+
This is useful if F and G were flawed in some way, or should not be
1020+
part of topicA. Note that the argument to `--onto` and the `<upstream>`
1021+
parameter can be any valid commit-ish.
1022+
1023+
10201024
RECOVERING FROM UPSTREAM REBASE
10211025
-------------------------------
10221026

0 commit comments

Comments
 (0)