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
执行过后自动切换到 new_branch
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
执行过后自动切换到 new_branch
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
删除无用的分支
git branch -d new_branch
git branch -d third_branch