Simply, I've done like this :
A------B-------C
\
\
B2
Now, I want to change B to B2.
A------B2-------C
Is it possible?
SOLUTION HISTORY:
I just added my work history.
$ git log
commit b671c70b C
commit f4acdc2b B
commit 56f38939 A
$ git checkout f4acdc2b
and I modified something... then committed with -amend option.
$ git commit -amend
$ git log
commit e2fd729 B'
commit 56f3893 A
Now, It became like this:
A------B-------C
\
\
B'
To rebasing B to B'
$ git checkout b671c70b
$ git rebase -i 56f38939
which opens the interactive editor
pick f4acdc2b B
pick 56f38939 A
just remove line pick f4acdc2b, save and quit.
If there is error error: could not apply b671c70b... C,
edit all merge conflicts and then,
$ git add .
$ git rebase --continue
$ git log
commit 914c6bc C'
commit 56f3893 A
$ git checkout 914c6bc
$ git rebase e2fd729
$ git log
commit 5c65190 C''
commit e2fd729 B'
commit 56f3893 A
Now, It looks like this.
A------B'-------C''
To completely remove B you must re-integrate B2 on A and C on B2.
git checkout C
git rebase B2
This rebases branch C on top of B2
A-------B------B2-------C'
(note that C' is a new commit)
But now you still have the B commit in the history. You can remove it with an interactive rebase.
git rebase -i A
which opens the interactive editor
pick 05c98ef B
pick e31d9f0 B2
pick 5d30d05 C
just remove line pick 05c98ef B, save and quit. After this B is removed and your history looks like this
A------B2'-------C''
You could interactively rebase your branch on top of B2 (on top of A actually, since you want B2 gone):
git checkout yourBranch # which references C)
git rebase -i A
# drop B
That would give:
A------B2'-------C'
(note that C' is C with a different SHA1, since its parent has changed)
(Same comment for B2, since its parent also changed)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With