Advantages of git fetch; git rebase origin master
Possible Duplicate:
git pull VS git fetch git rebase
I see some git
project recommended you to update the project via
git fetch; git rebase origin master
Are there any advantages in doing this, as compare to
git pull
from the perspective of opensource projects on github
, since you always trust the remote anyway.
If you haven't made any changes to your local copy of the branch, the two sets of commands will result in exactly the same history. The difference comes into play when you have made local commits to your current copy of the branch.
If you do git pull
any changes made on the remote will be merged into your local branch and you'll have a merge commit in the history. On the other hand, if you do a fetch followed by a rebase (or git pull --rebase
) your local changes will be replayed on top of the remote changes. This results in a cleaner history since you'll have less merge commits cluttering the history.
It also often makes your changes easier to merge upstream since the history before your new commits matches the history on the remote.
链接地址: http://www.djcxy.com/p/45114.html