The "ahead or behind by X commits" text in git status
is based on the state of the tracking branch for the current branch; remotes/origin/master
if you're on master
, for example.
When you run git pull
with both a remote and a branch specified, it fetches the new commits and merges them in to the current branch, but it does not update origin's remote tracking branches. Instead, it points to the just-fetched commits as FETCH_HEAD
.
Running git fetch
with no arguments specified, on the other hand, does update all of the remote tracking branches, so it makes the message go away. git pull
with no arguments does the same.
A subtle gotcha that I've hit a bunch of times myself! I wish git updated all remote tracking branches on every fetch against a particular remote, instead.