Fabrizio A
Fabrizio A

Reputation: 3152

Git rebase 2 commits shared by 2 branches

my current git branch model is:

                       C6 - C7 [branch B]
                      /
C1 - C2 - C3 - C4 - C5 [branch A]     

all commits are on my local pc. I'd like to squash C1 into C2 without change my repository branches model. If I checkout [branch A] and squash C1 and C2 then [branch b] has already existing C1 and C2 commit (not the C2' squashed commit). What's the right way to do it? Thanks.

Upvotes: 2

Views: 52

Answers (1)

VonC
VonC

Reputation: 1330002

Once you have rebased interactively branchA, you would need to rebase B on top of (the new) A:

                       C6 - C7 [branch B]
                      /
C1 - C2 - C3 - C4 - C5

C12 - C3' - C4' - C5' [branch A] 

git checkout branchB
git rebase branchA

                      C6' - C7' [branch B]
                     /
C12 - C3' - C4' - C5' [branch A] 

Upvotes: 6

Related Questions