If your Git version is very old (before 1.8.4), this behavior is normal.
If your Git version is 1.8.4 or later, this behavior is not normal.
(Use git --version
to find out what version of Git is installed.)
There are three (not two) entities in play here
Remember that there are two Gits involved during git fetch
: your Git, and another Git your Git calls up over the Internet-phone via https://github.com/xxxxxxx
. Your Git has a branch named master
. Their Git also has a branch named master. Your Git adds a third entity, a remote-tracking branch, in your own repository, named origin/master
.
The purpose of this remote-tracking branch is to remember "where origin's master was, the last time we talked with origin".
Next, note that:
git pull origin master
runs:
git fetch origin master && git merge FETCH_HEAD
In Git versions older than 1.8.4, the first step—the git fetch
part—fails to update your remote-tracking branch origin/master
when it retrieves new commits from the master
on origin
.
This turned out to be a mistake, so modern versions of Git, starting as far back as version 1.8.4, now update your origin/master
remote-tracking branch "opportunistically" when you fetch from origin
's master
. In other words, if your Git is not positively ancient, git fetch origin master
does update your origin/master
. But if it is that ancient, it fails to update your origin/master
.
Having updated, or failed to update, your origin/master
, your Git then goes on to perform that fast-forward
you reported:
Updating 1234567..qwertyu
Fast-forward
home/templates/test.html | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
so that your own master
matches the master
on origin
.
If your Git is modern, and updated origin/master
during the git fetch
step, your Git now compares your master
with your origin/master
and they match. If your Git is ancient, your Git now compares your master
with your origin/master
, and—whoa!—your master
is ahead of your origin/master
! But this is merely because your Git forgot to update its memory of origin's actual master.
To fix it, you can just run:
git fetch origin
or even just:
git fetch
which, even in these truly ancient Git distributions, will get your Git to update its memory of "where master
is on origin
".
(If you set origin/master
as the "upstream" for master
, you can stop using git pull
entirely by running git fetch && git merge
, or shorten your git pull
command to just git pull
. Both of these do pretty much the same thing at this point, but using git fetch && git merge
means you don't have to worry about this minor bug in ancient versions of Git. It also gives you more options, such as not running git merge
after all: you can run git rebase
instead, of that makes more sense.)