stack
stack

Reputation: 10228

How would working directory look like in tree diagram?

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:

  1. How does the whole process look like in git tree diagram?

  2. 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

Answers (1)

ElpieKay
ElpieKay

Reputation: 30868

After your first pull, the history is like: enter image description here

After you make some changes, the local branch moves on: enter image description here

Meanwhile, the remote repo has been updated by your co-worker: enter image description here

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: enter image description here

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'. enter image description here

Upvotes: 1

Related Questions