merge - Git - master change, rebase onto complex branches? -
merge - Git - master change, rebase onto complex branches? -
this question has reply here:
rebasing branch including children 2 answersso have complex local branch structure: main working local branch, , 2 other branches off of it. there new alter in master want in branches. best way propagate of branches? rebasing possible?
a---e---m master \ f---g---h local_branch_main |\ | i---j local_subbranch_1 \k---l local_subbranch_2
ideally, i'd want move branches reference off of new master commit (there no conflicts):
a---e---m master \ f---g---h local_branch_main |\ | i---j local_subbranch_1 \k---l local_subbranch_2
you can way
first do
git checkout local_branch_main git rebase master
if lucky , don't have conflicts repository this:
a---e---m master \ \ \ f'---g---h local_branch_main f |\ | i---j local_subbranch_1 \k---l local_subbranch_2
now here comes interessting part. can see commit f
, f'
contains same changes (if there no conflicts), f'
has parent commit , commit id. create visible naming f'
.
so can switch branch local_subbranch_1
, rebase on f'
git checkout local_subbranch_1 git rebase f'
of course of study must replase f'
commit id of f'
now repository looks this
a---e---m master \ \ \ f'---g---h local_branch_main f \ \ i---j local_subbranch_1 \ k---l local_subbranch_2
finally can checkout local_subbranch_2
, rebase on f'
, repository like
a---e---m master \ f'---g---h local_branch_main |\ | i---j local_subbranch_1 \ k---l local_subbranch_2
i have created demo repository can download here. can replay steps above on it.
git merge rebase
Comments
Post a Comment