homerboy homerboy - 1 year ago 65
Git Question

Checkout from non-working branch and want to rebase to master

I should've done

git checkout -b "test"
, but I accidentally checked out from
, so now all of the non-working code from
is clustered into my

I think the correct command is
git rebase master
, which updates my current branch's parent branch to be
, but it doesn't seem to be working. Is this the right command?

Answer Source

I am a little confused as to the structure of the your repository before and after the creation of the "test" branch. I am assuming that "branch1" is branching off of master, and now "test" is sitting on top of "branch1" like this:

  master      branch1      test, HEAD
- - * - - * - - * - - * - - *
    a     b     c     d     e

If this is the case then you can run git rebase --onto master branch1 test and that will change your repository to:

  master      branch1
- - * - - * - - *
    a\    b     c
      \                    test
       - - - - - - - * - - * 
                     d'    e'

If that is not the original situation, then I am confused.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download