Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Advantages of git fetch; git rebase origin master [duplicate]

Tags:

git

github

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.

like image 500
Ryan Avatar asked Aug 15 '12 10:08

Ryan


1 Answers

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.

like image 166
Michael Mior Avatar answered Sep 24 '22 10:09

Michael Mior