I have a branch A
in which I have made some changes a
, and then I created a new branch B
from A
to continue to make some changes b
, so that the total changes in B
are a, b
. Finally, someone else merged their changes c
into master, so the work tree now looks like this:
- c (master)
\
- a (A) - b (B)
Then I rebased A
to master, altering changes from a
to a'
and force pushed them to branch A
, so the work tree looks like this:
- c (master) - a' (A)
\
- a - b (B)
The question
How can I rebase B
to A
, so that only the new changes b
are altered and the work tree then looks like this:
- c (master) - a' (A) - b' (B)
If I try git rebase origin/A
when I'm on B
, then it tries to resolve commit a
against c, a'
, which I don't want, since I fear it will create a new commit a''
and then the work tree will look like this:
- c (master) - a' (A) - a'' - b' (B)
Is there a way to only rebase change b
now? (I have OFC tried to google this, but I didn't find anything to cover this case specifically)
EDIT:
I tried squashing a'
and b
on B
, but that was even worse, because now all the changes from b
were registered as conflicts. To illustrate, let's say that I:
- Added a new line
l1
ina
. - Changed that line to
l2
inb
. - This line was untouched in the other commit
c
. - Now it is a conflict, because
l1
was added ina'
, butl2
was added in the quashed commita'&b
.
a
ingit rebase --onto A a B
? I tried the start of the commit hash, but it didn't work very well. I unfortunately can't remember what the problem was (tried 5+ things, each failed in a different way). – Giovannagiovanni