Search code examples
gitgit-rebasepullgit-fetchgit-status

Aside from the resulting git tree structure, are there any important differences between git pull vs git fetch + git rebase?


I've worked on a dev team that preferred to use the method of git fetch and then git rebase rather than the method of git pull, before git pushing any changes to avoid merge conflicts.

Is there a specific reason besides the difference in the visual tree structure? According to http://mattsnider.com/git-rebase-versus-git-pull/ fetch & rebase

"will produce a cleaner history, without extraneous merge commits"

but between the two methods are there any other reasons to choose one over the other?


Solution

  • git pull = git fetch + git merge

    git pull --rebase or git pull -r= git fetch + git rebase

    No more, no less ;-) there is no magic. So you could do the second.

    The main advantage of doing fetch then rebase in 2 distinct steps is that the first doesn't modify your local branch (absolutely no risks) and so you could do it every time (you could even create a task that run it periodically).

    And once fetched, you could look at the history, compare it to your commits, and decide what you want to do and when...