The difference between git pull and git pull--rebase

Source: Internet
Author: User
Tags commit
The difference between the two can be expressed in the following relationship:
Git pull = git fetch + git merge
git pull--rebase = git fetch + git rebase


Now look at the difference between git merge and Git rebase.


Suppose there are 3 commits a,b,c.
On the basis of the remote branch origin, a branch named "MyWork" was created and submitted, while others made some changes to "origin" and submitted them.
In fact, this time e should not be submitted, because after the submission of conflicts. How to resolve these conflicts. There are two ways to do this:


1. Git merge
With the git pull command, the changes on the "origin" branch are brought down to the local commit merge (merge) into version m, but this will form the diamond in the diagram, which makes people very confused.


2. Git rebase
Create a new commit R,r file with the same contents as above M, but we will commit E to repeal when it does not exist (shown with dashed lines). As a result of this deletion, Xiao Li should not push other repository.rebase the benefit is to avoid the diamond production, keep the submission curve as straight line, so that everyone easy to understand.



In the process of rebase, sometimes there will be conflict, Git will stop rebase and let the user to resolve the conflict, after resolving the conflict, with the git add command to update the content, and then do not have to execute git-commit, directly execute git rebase-- Continue, so git will continue to apply the remaining patches.
At any time, you can use the git rebase--abort parameter to terminate Rebase's action, and the MyWork branch will return to the state it was in before Rebase started.
Http://blog.sina.com.cn/s/blog_88243b5e0101j38v.html

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.