It depends on your definition of B'
, C'
, and D'
.
If you want to move around patches, so that (in the first example) git diff B C
== git diff A C'
, then you want to "rebase" (not "reparent") using git rebase
as described by Emil.
If, on the other hand, you want to move around snapshots, then you really do want to "reparent". To do this, I suggest using git reparent
.
Most likely, you actually want to rebase and not reparent, but for reference, here are the commands for reparenting. They are somewhat complicated, because this is not a normal thing to do.
(The following assumes you are currently in a branch at D.)
1a. Reparenting I
git rebase -i B
# Select the "edit" command for C
git reparent -p A
git rebase --continue
1b. Reparenting II
git reparent -p B
1c. Reparenting III
git rebase -i A
# Select the "edit" command for B
git reparent -p C
git rebase --continue