About the difference between git rebase, git merge, git merge --no-ff of

Recently encountered when using git git merge and git rebase the difference, I do not understand the beginning, so he checked the Internet relevant information, and then found themselves with a bit github. Now we summed up the conclusions to others.

  A, merge and rebase

    First talk about, merge and mege -no-ff to achieve the same function, so we can put three commands into two categories, namely git rebase and git merge.

  1.1 in common

    First, talk about common ground, first of all realize the role of both merging two branches. The other two commands are sent to this branch, that is to say, if you have a main branch master, you have another one you used to write test code branch, so if you want to test on other branches merge or branch rebase into the master, you need to be in test using git merge / rebase master to test the code into the master.

  1.2 difference

    Like to take the difference between the two, the original role of the rebase is becoming group, in other words need to own a certain code is sent to the other branches of the branch, that is to say, a branch which is present as a basic, and then merge different, it is in accordance with the two branches as a basis, if the conflict between the two, it can not continue. This we may now understand a little more difficult, and so will be back to see to understand.

  1.2.1 git rebase difference and git merge --no-ff of

    The reason why these two commands, because these two commands after execution presented by the effect of people is better understood. Briefly, git rebase XXX (rebase branch), the result shown in FIG.

 

  As shown, the branch one is master branch, branch and second, test branch, if we want to test the rebase branch into the master branch, then he presented the effect is 1-2-3-4-5-6, in other words, he moved on to branch into the master branch test, if the reported conflict in the way we skip, then the result is that we end up with code written test. That branch of the test result to the master branch after the move .

  The git merge --no-ff is exactly the opposite, we do take the example of a result if we use git merge XXX --no-ff, so we get is 1-2-5-6-3-4- 7 (7 Why we explain later). In other words, the code we move on to the test before the merge. Specific see Figure .

  1.2.2 git difference merge and git merge --no-ff of

    ok, then we talk about the difference between git merge and git merge --no-ff, first of all, as I said earlier, the two functions realized in fact is the same, all code that implements the merger, the ultimate effect is the same realization but no-ff has a history that can be saved, give an example, such as we now have a main branch master records submitted to ABC, this time the separation of a branch feature submit records for the DEF, this time as the country with the master merge feature , then the result must be this: ABCDEF, in this case refers to the branch must F above, whereas if merge --no-ff, it would appear as a result ABCDEFG, when of course, from the results should be the same, but if you should happen to have the wrong part, requires a rollback, then you need to use no-ff, because this is more clear.

  1.3 application scenarios

    cherry-pick: this is well understood, if you want to submit a time, then you use cherry-pick on the line.

    rebase: merging the local branch generally used. The reason is this more clearly.

    merge: generally used for remote branch consolidation, because people only see the last time you submit.

  

 

 

 

 

  

Guess you like

Origin www.cnblogs.com/songyuchen/p/12082469.html