Difference between git pull --rebase and git pull --ff-only

£可爱£侵袭症+ 提交于 2019-12-04 07:29:51

问题


Let's say origin/master has commit A--B--C and my local/master has commit A--B--D.

What will happen if I use git pull --rebase ?

What will happen if I use git pull --ff-only ?

Is there any difference in the resulting commit tree ?


回答1:


What will happen if I use git pull --rebase ?

git pull --rebase is roughly equivalent to

git fetch
git rebase origin/master

i.e. your remote changes (C) will be applied before the local changes (D), resulting in the following tree

A -- B -- C -- D

What will happen if I use git pull --ff-only ?

It will fail.

git pull --ff-only corresponds to

git fetch
git merge --ff-only origin/master

--ff-only applies the remote changes only if they can be fast-forwarded. From the man:

Refuse to merge and exit with a non-zero status unless the current HEAD is already up-to-date or the merge can be resolved as a fast-forward

Since your local and remote branches have diverged, they cannot be resolved by a fast-forward and git pull --ff-only would fail.



来源:https://stackoverflow.com/questions/25430600/difference-between-git-pull-rebase-and-git-pull-ff-only

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!