'git merge'和'git rebase'有什么区别? [英] What's the difference between 'git merge' and 'git rebase'?

查看:112
本文介绍了'git merge'和'git rebase'有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

git merge git rebase

A , B C





然后开发者Dan创建了commit D ,并且开发者Ed创建了commit E





显然,这个冲突应该以某种方式解决。为此,有两种方法:

MERGE



两次提交 D E 仍然存在,但是我们创建了合并提交 M ,它继承了 D E 。然而,这会创建 diamond 形状,许多人都觉得这很令人困惑。
$ b REBASE





我们创建commit R ,其实际文件内容与上面的合并提交 M 相同。但是,我们摆脱了 E 的提交,就像它从未存在过的那样(用点 - 消失线表示)。由于这种消除, E 应该对开发者Ed是本地的,并且应该从未被推送到任何其他存储库。 rebase的优点是避免了钻石形状,并且历史保持不错的直线 - 大多数开发人员都喜欢它!


What's the difference between git merge and git rebase?

解决方案

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!

这篇关于'git merge'和'git rebase'有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆