When git merge merge / squash merge / rebase merge the difference

merge

1. merge

$ git checkout master
$ git merge dev

This is the basic merge, will submit a branch of history intact copied, if the master afterwards have a new submission, it will automatically create a commit additional information at the time of this merge is used to record this merge operations .

2. squash merge

$ git checkout master
$ git merge --squash dev

Literally, it would decrease compared to merge branches merged records, will be compressed to a commit record. squash merge essence is to save the dev branch changes to the local master, then also you need to manually submit it, so the final submitter person operation into a master branch, and this may be drawbacks.

3. rebase go

$ git checkout dev
$ git rebase -i master
$ git checkout master
$ git merge dev

rebase merge squash merge can be the perfect solution to the problem may change the original submitter.

First rebase this concept could go under if do not understand is understood here to be the meaning rebase, personally think that, on the one hand and to look at the master branch synchronization information, so as not to master the dev and after the bifurcation, there has been additional updates; the other on the one hand, can really solve the pain points squash merge is -iinteractive mode, enter the text edit box, specify the dev by themselves relative to these "patches" master new generated when the rebase specific on how to apply to the current dev branch.

So rebase merge is very flexible, you can not do anything, the default strategy:

pick xxxxxxx A
pick xxxxxxx B
pick xxxxxxx C

You can also commit all combined into one, to save and exit, will enter the text edit box for editing information submitted again after the merger:

pick xxxxxxx A
squash xxxxxxx B
squash xxxxxxx C

May also be as a substandard, wherein merging only a few, such as the A, B, C is the integration of three commit record AB, C two records:

pick xxxxxxx A
fixup xxxxxxx B
pick xxxxxxx C

Defined text edit box instruction reasonable, it should be smooth rebase is successful, then you can git log to see whether you do so.
Finally, git merge dev on the master branch is a routine operation.

So squash merge and rebase merge in a number of merger when a difference is that the former only merge merge into one, and the latter in advance on the way to rebase the integration of multiple commit information.


reference:

  1. Three operations of the merge git merge, squash merge, and rebase merge

Guess you like

Origin www.cnblogs.com/nicholaswang/p/11801563.html