manish ma
manish ma

Reputation: 2028

Confusion about git pull --rebase

According to a tutorial I found : https://www.atlassian.com/git/tutorials/syncing/git-pull

git pull --rebase appends commits to your local tree.

    A - B - C (origin/master)
  /
D - E - F - G (local master)

After git pull --rebase on local the tutorial calims it should look like:

    A - B - C (origin/master)
  /
D - E - F - G - A - B - C (local master)

I would expect it to be like so :

  A - B - C (origin/master)
 /
D - A - B - C - E' - F' - G' (local master)

Am I missing something? or maybe they are wrong?

Upvotes: 2

Views: 174

Answers (2)

marcolz
marcolz

Reputation: 2970

You are correct.

That page is wrong, not only the graph, but also the text accompanying it:

In this diagram, we can now see that a rebase pull does not create the new H commit. Instead, the rebase has copied the remote commits A--B--C and appended them to the local origin/master commit history.

The manual page is more clear:

-r, --rebase[=false|true|preserve|interactive]

When true, rebase the current branch on top of the upstream branch after
fetching. If there is a remote-tracking branch corresponding to the
upstream branch and the upstream branch was rebased since last fetched,
the rebase uses that information to avoid rebasing non-local changes.

Upvotes: 2

Schwern
Schwern

Reputation: 164639

If you have this.

    A - B - C (origin/master)
  /
D - E - F - G (master)

After git pull --rebase, assuming no new commits are fetched, you will have this.

D - A - B - C [origin/master]
             \
              E' - F' - G' [master]

E, F, and G are replayed on top of origin/master.

Note there's only one A, B, and C. Remotes and local branches all share the same commit tree.

Upvotes: 1

Related Questions