@@ -111,87 +111,6 @@ will result in:
111
111
D---E---A'---F master
112
112
------------
113
113
114
- Here is how you would transplant a topic branch based on one
115
- branch to another, to pretend that you forked the topic branch
116
- from the latter branch, using `rebase --onto` .
117
-
118
- First let's assume your 'topic' is based on branch 'next' .
119
- For example, a feature developed in 'topic' depends on some
120
- functionality which is found in 'next' .
121
-
122
- ------------
123
- o---o---o---o---o master
124
- \
125
- o---o---o---o---o next
126
- \
127
- o---o---o topic
128
- ------------
129
-
130
- We want to make 'topic' forked from branch 'master' ; for example,
131
- because the functionality on which 'topic' depends was merged into the
132
- more stable 'master' branch. We want our tree to look like this:
133
-
134
- ------------
135
- o---o---o---o---o master
136
- | \
137
- | o'--o'--o' topic
138
- \
139
- o---o---o---o---o next
140
- ------------
141
-
142
- We can get this using the following command:
143
-
144
- git rebase --onto master next topic
145
-
146
-
147
- Another example of --onto option is to rebase part of a
148
- branch. If we have the following situation:
149
-
150
- ------------
151
- H---I---J topicB
152
- /
153
- E---F---G topicA
154
- /
155
- A---B---C---D master
156
- ------------
157
-
158
- then the command
159
-
160
- git rebase --onto master topicA topicB
161
-
162
- would result in:
163
-
164
- ------------
165
- H'--I'--J' topicB
166
- /
167
- | E---F---G topicA
168
- |/
169
- A---B---C---D master
170
- ------------
171
-
172
- This is useful when topicB does not depend on topicA.
173
-
174
- A range of commits could also be removed with rebase. If we have
175
- the following situation:
176
-
177
- ------------
178
- E---F---G---H---I---J topicA
179
- ------------
180
-
181
- then the command
182
-
183
- git rebase --onto topicA~5 topicA~3 topicA
184
-
185
- would result in the removal of commits F and G:
186
-
187
- ------------
188
- E---H'---I'---J' topicA
189
- ------------
190
-
191
- This is useful if F and G were flawed in some way, or should not be
192
- part of topicA. Note that the argument to `--onto` and the `<upstream>`
193
- parameter can be any valid commit-ish.
194
-
195
114
MODE OPTIONS
196
115
------------
197
116
@@ -237,6 +156,8 @@ As a special case, you may use "A\...B" as a shortcut for the
237
156
merge base of A and B if there is exactly one merge base. You can
238
157
leave out at most one of A and B, in which case it defaults to HEAD.
239
158
159
+ See TRANSPLANTING A TOPIC BRANCH WITH -- ONTO below for examples.
160
+
240
161
-- keep-base::
241
162
Set the starting point at which to create the new commits to the
242
163
merge base of `<upstream>` and `<branch>` . Running
@@ -1015,6 +936,91 @@ consistent (they compile, pass the testsuite, etc.) you should use
1015
936
after each commit, test, and amend the commit if fixes are necessary.
1016
937
1017
938
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
+
1018
1024
RECOVERING FROM UPSTREAM REBASE
1019
1025
-------------------------------
1020
1026
0 commit comments