Git中合并与变基的区别
Git中合并与变基的区别


在 feature
分支进行了两次提交,此时其它人也进行了两次提交,并且合并到了 master
分支,此时是无法push到远程仓库的,需要进行分支合并。
Merge
将两个分支合并,将分支的历史记录合并在一起。并创建一个新的合并提交 merge commit。

Rebase
将一个分支上的提交应用到另一个分支的基础上,重新排列提交历史。不会创建新的合并提交,而是将提交重新放置,使分支历史看起来像是线性的一条直线。

示例
将
develop
分支的最新变更应用到release
分支上。
# 切换到 release 分支上
git rebase develop
# Successfully rebased and updated refs/heads/release.
最后更新于