@@ -113,87 +113,6 @@ will result in:
113
113
D---E---A'---F master
114
114
------------
115
115
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
-
197
116
MODE OPTIONS
198
117
------------
199
118
@@ -239,6 +158,8 @@ As a special case, you may use "A\...B" as a shortcut for the
239
158
merge base of A and B if there is exactly one merge base. You can
240
159
leave out at most one of A and B, in which case it defaults to HEAD.
241
160
161
+ See TRANSPLANTING A TOPIC BRANCH WITH -- ONTO below for examples.
162
+
242
163
-- keep-base::
243
164
Set the starting point at which to create the new commits to the
244
165
merge base of `<upstream>` and `<branch>` . Running
@@ -1017,6 +938,91 @@ consistent (they compile, pass the testsuite, etc.) you should use
1017
938
after each commit, test, and amend the commit if fixes are necessary.
1018
939
1019
940
941
+ TRANSPLANTING A TOPIC BRANCH WITH --ONTO
942
+ ----------------------------------------
943
+
944
+ Here is how you would transplant a topic branch based on one
945
+ branch to another, to pretend that you forked the topic branch
946
+ from the latter branch, using `rebase --onto`.
947
+
948
+ First let's assume your 'topic' is based on branch 'next'.
949
+ For example, a feature developed in 'topic' depends on some
950
+ functionality which is found in 'next'.
951
+
952
+ ------------
953
+ o---o---o---o---o master
954
+ \
955
+ o---o---o---o---o next
956
+ \
957
+ o---o---o topic
958
+ ------------
959
+
960
+ We want to make 'topic' forked from branch 'master'; for example,
961
+ because the functionality on which 'topic' depends was merged into the
962
+ more stable 'master' branch. We want our tree to look like this:
963
+
964
+ ------------
965
+ o---o---o---o---o master
966
+ | \
967
+ | o'--o'--o' topic
968
+ \
969
+ o---o---o---o---o next
970
+ ------------
971
+
972
+ We can get this using the following command:
973
+
974
+ git rebase --onto master next topic
975
+
976
+
977
+ Another example of --onto option is to rebase part of a
978
+ branch. If we have the following situation:
979
+
980
+ ------------
981
+ H---I---J topicB
982
+ /
983
+ E---F---G topicA
984
+ /
985
+ A---B---C---D master
986
+ ------------
987
+
988
+ then the command
989
+
990
+ git rebase --onto master topicA topicB
991
+
992
+ would result in:
993
+
994
+ ------------
995
+ H'--I'--J' topicB
996
+ /
997
+ | E---F---G topicA
998
+ |/
999
+ A---B---C---D master
1000
+ ------------
1001
+
1002
+ This is useful when topicB does not depend on topicA.
1003
+
1004
+ A range of commits could also be removed with rebase. If we have
1005
+ the following situation:
1006
+
1007
+ ------------
1008
+ E---F---G---H---I---J topicA
1009
+ ------------
1010
+
1011
+ then the command
1012
+
1013
+ git rebase --onto topicA~5 topicA~3 topicA
1014
+
1015
+ would result in the removal of commits F and G:
1016
+
1017
+ ------------
1018
+ E---H'---I'---J' topicA
1019
+ ------------
1020
+
1021
+ This is useful if F and G were flawed in some way, or should not be
1022
+ part of topicA. Note that the argument to `--onto` and the `<upstream>`
1023
+ parameter can be any valid commit-ish.
1024
+
1025
+
1020
1026
RECOVERING FROM UPSTREAM REBASE
1021
1027
-------------------------------
1022
1028
0 commit comments