Suppose originally there were 3 commits, A,B,C:

Then developer Dan created commit D, and developer Ed created commit
E:

Obviously, this conflict should be resolved somehow. For this, there are 2 ways:
MERGE:

Both commits D and E are still here, but we create merge commit
M that inherits changes from both D and E. However, this creates
diamond shape, which many people find very confusing.
REBASE:

We create commit R, which actual file content is identical to that of merge commit
M above. But, we get rid of commit E, like it never existed (denoted by dots - vanishing line). Because of this obliteration,
E should be local to developer Ed and should have never been pushed to any other repository. Advantage of rebase is that
diamond shape is avoided, and history stays nice straight line - most developers love that!
转自:Stackoverflow
PS:老是觉得国外技术人员的解答更形象易懂一点。
本文详细解释了Git中Merge和Rebase两种合并方式的原理、优缺点及使用场景,帮助开发者更好地解决代码冲突问题。
886

被折叠的 条评论
为什么被折叠?



