I have 3 branches
A
(not managed by me)B
(managed by me)main
My B
branch is dependant from the branch A
and A
is already squashed in the main
branch.
This graph shows the curret situation.
I want to move (rebase) B
on the comment corresponding to Squashed A
.
I used the command git checkout B && git rebase main
to rebase it but I have a lot of conflicts to manage and is not so easy to avoid problems or bugs.
I have find out This post but I have an already squashed branch (not Squashed by me).
How can I have this result with few commands without having so much throubles with few ?
The question you linked actually contains the answer to your question:
# With start exclusive, end inclusive
# git rebase --onto <where> <current-start> <current-end>
# Presented in a specific way for your case:
# git rebase --onto <squashed-commit> <old-non-squashed-branch-or-revision> <feature-branch>
# That is:
git rebase --onto main A B
This should give you exact same content as B
before the operations.
You can double check by creating a tag before doing anything and using git diff <tag-before-ops> B
after the operations.
Important: as suggested by @eftshift0, this is assuming that A
has not changed and still is in the state before squashing.
If that's not the case, you may use any ref pointing to the state of A
before squashing like B~2
in this very example or the commit hash directly.