I'm reading the Pro Git book and get stuck on rebasing.
Below is the scenario:
We can see that the remote did a rebasing, (not a good practice, because someone else might work based on it).
Then the author says:
If you do a git pull, you’ll create a merge commit which includes both lines of history, and your repository will look like this:
I do not understand why git pull
will automatically merge C4
and C7
, because we know that normally git pull
does not do merges for you and you have to merge by yourself, so why in this case does git pull
merge for you?
Edit:
Sorry, I typed and thinked too fast,I was talking about git fetch
that doesn't automatically merge, git pull
does merge and git pull
= git fetch
+ git merge
.
So my question is, why the author says:
When you rebase stuff, you’re abandoning existing commits and creating new ones that are similar but different. If you push commits somewhere and others pull them down and base work on them, and then you rewrite those commits with git rebase and push them up again, your collaborators will have to re-merge their work and things will get messy when you try to pull their work back into yours.
I'm really confused, if the developer didn't do rebasing after the merge so we have the picture in step 1 as the beginning, , then the developer added a new commit called C8
right after C6
, then if I call git pull
on my computer, C8
will still need to be merged with C7
, so it will have to re-merge work anyway, it cannot be avoided and things will get messy, so what's the problem with that?