Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to move all commits from a branch to another?

Tags:

git

The scenario is this:

X1--X2--X3--X4--X5--X6 (master)
             \
              D1--D2--D3 (dev)
                       \
                        B1--B2--B3 (bug1)

I want to move all commits from bug1 branch to master branch and get rid of bug1 branch. In this case:

X1--X2--X3--X4--X5--X6--B1--B2--B3 (master)
             \
              D1--D2--D3 (dev)

What's the best option to do this?

like image 807
Ivan Avatar asked Feb 08 '12 11:02

Ivan


1 Answers

It should be a classic case of git rebase --onto

git rebase --onto master dev bug1
git checkout master
git merge bug1 # fast-forward merge

See also the ProGit Book for another example of rebase --onto.

like image 69
VonC Avatar answered Oct 08 '22 09:10

VonC