I think you're misunderstanding how branches work in git. They're not whole histories, just pointers to a single commit. That is, foo
is really just a synonym for d
, and bar
is a synonym for g
. Rebasing bar
doesn't affect foo
in any way.
If you want to set foo to your new d
(let's call it d'
), just do:
git checkout foo
git reset --hard d'
Here's an example based on yours:
a <- b <- c <- d <- e <- f <- g
^ ^
| |
foo bar
Now, after you do the rebase on bar
, you have divergent history:
/- c <- d
/ ^
a <- b <- |
\ foo
\
\- c' <- d' <- e' <- f' <- g'
^
|
bar
All you want to do is point foo
at d'
, using the reset
command described above:
a <- b <- c' <- d' <- e' <- f' <- g'
^ ^
| |
foo bar
This operation orphans c
and d
- they'll get garbage collected eventually.