3

This is my graph:

Branch A    a-->b
                |
                v
Branch B        b-->c

I have branch B that came out of branch A, from commit b.
I did a commit on branch B called c.

Now let's say I update commit b of branch A with git commit --amend to b'

Branch A    a-->b'
                |
                v
Branch B        b-->c

How do I update comit b on branch B to be the exact b' ?

Thanks

hudac
  • 2,584
  • 6
  • 34
  • 57

1 Answers1

3

Actually, the grap is

a--b (A)
    \
     c (B)

After amend, you would have a new b' (marking b as tmp):

a--b' (A)
 \
  b--c (B)
(tmp)

You would need to rebase B onto A:

git rebase --onto A tmp B

a--b' (A)
    \
     c' (B)

As divyum comments, you can also merge, but that would add to A, and duplicate b commit between, resulting in possible conflicts:

a--b'--M (A)
 \    /
  b--c (B)

I prefer cherry-picking or rebasing.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250