Initial:
New_branch n1--n2
|
Master M1--M2--M3
------------------------------------
1. Merge
$ (Master) git merge New_branch
Master M1--m2--n1--m3--n2--merge Branch New_branch
2. Rebase
$ (master) git rebase master New_branch
Automatically switches to new_branch after execution
New_branch m1--m2--m3--n1--n2
$ (new_branch) git checkout Master
$ (Master) git merge New_branch
Fast-forward
Master M1--M2--M3--N1--N2
3. Rebase--onto
Third_branch T1--t2
|
New_branch n1--n2
|
Master M1--M2--M3
Master, New_branch:no changes m1--m2--m3
Third_branch M1--m2--m3--t1--t2
$ (Master) git merge Third_branch
Fast-forward
Master M1--m2--m3--t1--t2
$ (master) git rebase master New_branch
Automatically switches to new_branch after execution
New_branch m1--m2--m3--t1--t2--n1--n2
git checkout Master
$ (Master) git merge New_branch
Fast-forward
Master M1--M2--M3--T1--T2--N1--N2
Delete useless branches
Git branch-d new_branch
Git branch-d third_branch
git rebase and git merge