git pull,git fetch和git rebase有什么区别?

时间:2017-02-12 05:54:07

标签: git git-pull git-fetch

git pullgit fetchgit rebase之间有什么区别?我觉得拉和取相同。

1 个答案:

答案 0 :(得分:3)

抓取:使用远程更改更新本地,但不合并与任何本地分支 STRONG>。

更新本地合并更改当前分支

  • git fetch:从原点获取最新更改(不合并)

  • git pull = git fetch + git merge

  • 如果您将feature分支到master分支。 git rebase master,它会使feature分支commits/changes保持最高位置。

    假设您在master分支(A - > C)中有两次提交,并且feature分支中有两次提交(B - > { {1}})。

    假设您在D分支(feature)。现在,如果您git checkout feature然后提交历史记录:

    merge master

    此处(previous commit) - A -- C <- master \ \ B -- D -- M <- feature M

    对于new-merge-commit-sha,提交历史记录:(rebase master - &gt; A - &gt; C - &gt; B')。

    < / LI>