-
To answer this question, let's think
about what commits were present on
-
GitHub and in your local repository
before and after git fetch.
-
When you cloned the repository,
-
the latest commit on it was Larry's
commit adding the chili recipe, so
-
that also became the latest
commit in your local repository.
-
Of course,
there were other previous commits, but
-
I'm leaving them out here for
the sake of space.
-
Now you made a commit
adding a new spice, so
-
that commit is also present
in your local repository.
-
And that's where your master branch is.
-
origin/master still points to
the commit that was on the remote at
-
the time that you cloned.
-
After you cloned, Sarah added
the no cumin commit on GitHub, but
-
your origin/master branch
won't reflect that yet.
-
So, this is the state
of master on GitHub.
-
Now, this was the state of
-
both repositories right
before you ran git fetch.
-
So, if you ran git log origin/master,
you should have seen that Larry's commit
-
adding the chili recipe was present,
but your commit adding a new spice and
-
Sarah's commit removing cumin were not
present on the origin/master branch.
-
If you run git status, you should have
seen that your branch was ahead of
-
origin/master by one commit.
-
This makes sense because git log and git
status both run without internet access.
-
Suppose you were somewhere
without internet access when you
-
ran these commands.
-
Your local git repository would have
no idea that the cumin commit existed.
-
So, of course, the cumin commit
wouldn't be shown when you ran git
-
log origin/master.
-
And git status wouldn't know that your
branches were actually out of sync.
-
It thinks that your
branch is just ahead.
-
Now when you run git fetch,
git fetches the no cumin commit and
-
updates the branch origin/master
to point to that new commit.
-
Your local master still points at
the new spice commit like it did before.
-
So at this point, you have a local
copy of the no cumin commit saved, and
-
you can access it via git log.
-
If you run git log now,
you'll see both the no cumin commit and
-
the chili commit.
-
You still won't see your new
spice commit since that's only on
-
your local master branch.
-
Now, since both origin slash master and
-
master have one commit that
is not present on the other,
-
git status will show that your branch
is out of sync with origin/master.