git change origin of a branch (rebase)

f'I have the following:

A---B---C-----D--   branch dev
     \--C'-E-/      branch test

I did it bad: C and C' are almost the same commits, it would make more sense if I could make branch test start on C, instead of B.

How could I do that?, I guess rebase, but I'm not sure how to use it, thx

edit: wasn't clear what I'd like:

A---B---C-----D--   branch dev
         \-E-/      branch test


A--B--D--E--D if not possible


You could rebase it on top of a temporary branch (made from C) See git rebase and Rebasing, plus git branch.

git branch tmp C
git checkout test

# rebase the current branch (test) on top of tmp
git rebase tmp  

git branch -d tmp

That should give you:

A---B---C-----D--       branch dev
         \--C''-E'-/      branch test

I have left C' (here as C'') because C' isn't exactly the same than C. But as ams comments, if you need C' gone, you would

git rebase -i tmp

That would get you an interactive rebase, allowing for C' to be removed completely, replaying only E on top of C.

You can rebase just the piece you want onto C:

A---B---C-----D--   branch dev
      C'-E--      branch test

# git rebase --onto [new base] [starting after this commit] [ending at this commit]
git rebase --onto C C' E

A---B---C-----D--   branch dev
          E--      branch test

It's the same concept as cherry-picking, except the test branch pointer moves along with the rebased commits.

(Note that the C' commit will be unreachable after the rebase, but you can get back to it with git reflog.)

Need Your Help

Why doesn't adding these floats add up?

c++ windows floating-point

I know that these floating point questions are probably the most asked question here at stack overflow, but I can't find something that looks like mine. In windows (visual studio) compiled as 32 b...