git pull --rebase vs git rebase : what's the danger?

sab picture sab · Jun 24, 2016 · Viewed 15.9k times · Source

I don't understand the difference between git pull --rebase and git rebase, without any other options.

I don't understand if they are safe, a good practice, or very dangerous.

Can I break the historic of commit by doing a git pull --rebase in local?

Answer

Luis picture Luis · Jun 24, 2016

I don't recommend rebasing at all but just for private branches. By private I mean branches that you're pretty sure only you have pulled.

A rebase changes the starting point of the branch to some newer commit, thus merging all the commits to that point. This could lead to merge conflicts to people that had in their repository the old branch base. I would recommend plain merge always and leave rebasing only for certain situations (feature branches, for example).

Regarding your question:

  • git rebase rebases the branch you want.
  • git pull --rebase performs a fetch + rebase in the branches you pull. Normally a pull would fetch + merge.