git pull,git fetch和git rebase之间有什么区别?
git pull,git fetch和git rebase之间有什么区别?
这个问题已经有答案了: “ git pull”和“ git fetch”有什么区别?
< p> < code> git pull </ code>,< code> git fetch </ code>和< code> git rebase </ code>之间有什么区别?我感觉 pull 和 fetch 是一样的。</ p>
admin 更改状态以发布 2023年5月21日
获取(fetch):从远程更新本地但不与本地任何分支合并。
拉取(pull):更新本地并将更改与当前分支合并。
-
git fetch
:从origin获取最新更改(不合并) -
git pull
=git fetch
+git merge
-
如果您将
feature
分支变基到master
分支。执行git rebase master
,则它将保留feature
分支的commits/changes
最前面。假设您的
master
分支中有两个提交(A
->C
),而feature
分支中有两个提交(B
->D
)。假设您在
feature
分支中(git checkout feature
)。现在,如果您合并master
,则提交历史记录为:(previous commit) - A -- C <- master \ \ B -- D -- M <- feature
这里,
M
是new-merge-commit-sha
。对于
rebase master
, 提交历史记录如下(A
->C
->B'
->D'
)。