Documentation: Transplanting branch with git-rebase --onto
Added example of transplantig feature branch from one development branch (for example "next") into the other development branch (for example "master"). [jc: talking Carl's advice this contains both examples sent to the list by Jakub in his original message.] Signed-off-by: Jakub Narebski <jnareb@gmail.com> Signed-off-by: Junio C Hamano <junkio@cox.net>
Jakub Narebski committed
Nov 6, 2006 at 19:12 UTC
e52775f43857f377aa2aa69f82ac2d2f26dc6297
1 file changed
+57
-8
Documentation/git-rebase.txt
+57
-8
@@ -51,20 +51,69 @@ would be:
51
D---E---F---G master
52
------------
53
54
-While, starting from the same point, the result of either of the following
55
-commands:
54
+The latter form is just a short-hand of `git checkout topic`
55
+followed by `git rebase master`.
56
57
- git-rebase --onto master~1 master
58
- git-rebase --onto master~1 master topic
57
+Here is how you would transplant a topic branch based on one
58
+branch to another, to pretend that you forked the topic branch
59
+from the latter branch, using `rebase --onto`.
60
60
-would be:
61
+First let's assume your 'topic' is based on branch 'next'.
62
+For example feature developed in 'topic' depends on some
63
+functionality which is found in 'next'.
64
65
------------
63
- A'--B'--C' topic
64
- /
65
- D---E---F---G master
66
+ o---o---o---o---o master
67
+ \
68
+ o---o---o---o---o next
69
+ \
70
+ o---o---o topic
71
+------------
72
+
73
+We would want to make 'topic' forked from branch 'master',
74
+for example because the functionality 'topic' branch depend on
75
+got merged into more stable 'master' branch, like this:
76
+
77
+------------
78
+ o---o---o---o---o master
79
+ | \
80
+ | o'--o'--o' topic
81
+ \
82
+ o---o---o---o---o next
83
------------
84
85
+We can get this using the following command:
86
+
87
+ git-rebase --onto master next topic
88
+
89
+
90
+Another example of --onto option is to rebase part of a
91
+branch. If we have the following situation:
92
+
93
+------------
94
+ H---I---J topicB
95
+ /
96
+ E---F---G topicA
97
+ /
98
+ A---B---C---D master
99
+------------
100
+
101
+then the command
102
+
103
+ git-rebase --onto master topicA topicB
104
+
105
+would result in:
106
+
107
+------------
108
+ H'--I'--J' topicB
109
+ /
110
+ | E---F---G topicA
111
+ |/
112
+ A---B---C---D master
113
+------------
114
+
115
+This is useful when topicB does not depend on topicA.
116
+
117
In case of conflict, git-rebase will stop at the first problematic commit
118
and leave conflict markers in the tree. You can use git diff to locate
119
the markers (<<<<<<) and make edits to resolve the conflict. For each