I have a Topic
branch which I continuous do development on it. From time to time I need to put the content back to Main
Branch. I use rebase
to do the merge for the first time ( T1
to B
as shown in the picture). After that both Topic
and Main
branch continue to grow, at certain point T2
I want to rebase again
Problem comes here, what I want is to apply commits between T1
and T2
one by one to Main
Head, however, git still tries to apply commits between T0
to T2
to Main
head. In another word, git are not aware of the fact that commits between T0
and T1
has already been rebased to Main
. This is causing many unnecessary conflicts.
I read through the git rebase documentation, but seems there is not a parameter which can specify the starting point to calculate the delta patches
. So I am stuck at this point.
Any one can help me out?
You are mixing up merge
and rebase
.
You have merged T0.. T1 into the main branch, you have not rebased them onto the main branch. You should choose your strategy: rebase or merge always.
If you would have rebased T0..T1 on the main branch, your graph would have looked like this:
A main branch start
...
B <- main branch
T0'
...
T1' <- topic branch
That is: a linear history: Short recap:
merge
creates a single merge commit, history of each branch remains exactly as it was (as in your example) rebase
rewrites the history of your (topic) branch. The result is a linear history.Find the answer after reading rebase doc
git rebase --onto main T1 T2
It calculate the delta between [T1, T2] and apply them one by one to main
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.