git rebase and git merge

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.