Search code examples
gitgit-rebase

git pull --rebase


Start situation (no unpushed changes, > indicates the current branch):

o C [> master][origin/master]
|
o B
|
o A
|
...

After a git fetch the log structure often looks like

o E [origin/master]
|
o C'
|
o B'
|
o D
|
| o C [>master]
| |
| o B
|/
o A
|
...

Now git rebase origin/master master often produces conflicts. Is git pull --rebase smarter and just uses git reset to make master also point to E if master==origin/master initially?


Solution

  • git pull --rebase is similar to what the following would do:

    git fetch
    git rebase
    

    So in your case it will leave the repository like this:

    o C [> master]
    |
    o B
    |
    o E [origin/master]
    |
    o C'
    |
    o B'
    |
    o D
    |
    o A
    |
    ...
    

    Note that the two commits you have are different from origin where re-created on top of commit E.