< p >Git pull,git fetch和git rebase之间有什么区别?我感觉pull和fetch是一样的。
Fetch: 从远程仓库更新本地代码,但不会和任何本地分支合并。
Pull: 从远程仓库更新本地代码,并将更改与当前分支合并。
git fetch
: Get the latest changes from origin (no merge)
git pull
= git fetch
+ git merge
If you rebase feature
branch onto master
branch. git rebase master
, it would keep the feature
branch commits/changes
top.
Say you have two commits in master
branch (A
-> C
) and two commits in feature
branch (B
-> D
).
Assume you are in feature
branch (git checkout feature
). Now if you merge master
then commit history:
(previous commit) - A -- C <- master
\ \
B -- D -- M <- feature
Here, M
for new-merge-commit-sha
.
For rebase master
, commit history: (A
-> C
-> B'
-> D'
).
git merge master
将会导致比你展示的更为复杂的提交历史。 - Code-Apprenticefeature
。执行 git checkout feature
,然后执行 git rebase master
。这样就会将 feature
分支变基到 master
分支上。 - Sajib Khan
git pull --rebase
相当于后面两个命令。 - Pockets