美文网首页Git
git rebase 和 git merge 区别

git rebase 和 git merge 区别

作者: GYLEE | 来源:发表于2017-04-01 15:32 被阅读99次

一直在使用这两个命令,但对两者之间的细节没有在意过,今天受启发,具体的研究一下 。

  • 在合并分支时,git rebase 会将分支的 commit 信息一并合如 master 分支 , 而 git merge 不会,它会在主分支外保留其他分支的 commit 信息 。
rebase 和 merge 的提交历史图
  • 将分支删除后 ,两种情况下的 commit 信息都不会消失 , 但是 git merge 会留下合并分支的记录 。
rebase 和 merge 删除分支后的区别

个人爱好: 为保证代码提交历史的条理性,建议使用 git rebase 操作 。

git rebase 使用步骤

分支 master 和 branch (当前分支 master)

git rebase branch

编辑过程中存在冲突,解决完冲突后,执行:
git add xx
继续变基
git rebase --continue
查看代码树
git log --graph

相关文章

网友评论

    本文标题:git rebase 和 git merge 区别

    本文链接:https://www.haomeiwen.com/subject/uaeiottx.html