Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Move branch to another branch

I have started doing some work on a branch which I have in term realised was the wrong branch. Is there a way to move a branch to a different branch.

For example:

A -- B -- C -- D -- HEAD  \-- E -- F -- G -- H -- I -- J       \-- K -- L 

And I want this:

A -- B -- C -- D -- HEAD  \    \-- K -- L   \    \-- E -- F -- G -- H -- I -- J 
like image 525
user204088 Avatar asked Jan 30 '14 14:01

user204088


1 Answers

Let's say you've named your branches like so:

    A -- B -- C -- D (master)      \-- E -- G -- H -- I -- J (current-parent)           \-- K -- L (my-branch) 

What you want to do is rebase my-branch onto the B commit like so:

    git rebase current-parent my-branch --onto B 
like image 129
Wolf Avatar answered Sep 28 '22 17:09

Wolf