Nandish A
Nandish A

Reputation: 1705

What exactly does a git pull --rebase does

What exactly happens when I run the command

git pull --rebase on master branch

Does this rewrite my master branch history

Is it a good way to pull changes or should we

 1. Git fetch 
 2. Git merge

Upvotes: 4

Views: 412

Answers (1)

jshawl
jshawl

Reputation: 3483

When you git pull --rebase, a few things happen:

  1. git fetch origin master

    -just using origin/master as an example

  2. git rebase origin/master

    • moves all of your commits after the commits on origin/master

At this point, you can now push to origin and your commits will be applied on top of all other commits cleanly.

Without the --rebase flag, you'd end up with a merge commit; one that has two parents: your master branch and the work on origin/master

Here are a few helpful resources:

  1. http://viget.com/extend/only-you-can-prevent-git-merge-commits
  2. http://gitready.com/advanced/2009/02/11/pull-with-rebase.html

Upvotes: 3

Related Questions