Reputation: 10228
I get the last commit which exists in the master branch like this:
$ git pull origin master
Then I make some changes in it. Noted that, in the same time (whenever I was working on the project), my co-worker has pushed some new commits to the master branch.
So I have to rebase my changes first and then push it to the master branch. Here is my commands:
git pull origin master --rebase
git push origin master
Now I want to know:
How does the whole process look like in git tree diagram?
Also, can I write git pull origin master --rebase
the other way? I mean is --rebase
a shorten for $ git checkout workingDirecotry
and $ git rebase master
?
Upvotes: 1
Views: 77
Reputation: 30868
After your first pull, the history is like:
After you make some changes, the local branch moves on:
Meanwhile, the remote repo has been updated by your co-worker:
Then you run git pull origin master --rebase
, which is equivalent to git fetch origin master && git rebase origin/master
.
As a result of git fetch origin master
:
And then git rebase origin/master
. D
and E
are transplanted from the old base C
onto the new base N
. master
also moves from the old head E
to the new head E'
.
Upvotes: 1