Information Technology Reference
In-Depth Information
Messages [ahead x] and [behind y]
As you have already seen the relation between the local tracking branch and the remote
tracking branch can be checked with the $ git status -sb command. In a case
where the local tracking branch and the remote tracking branch point to different revi-
sions, the output of this command contains sections [ahead N, behind M] , as in:
## master...origin/master [ahead 2]
## master...origin/master [behind 2]
## master...origin/master [ahead 2, behind 1]
The [ahead 2] message indicates that the local tracking branch is two revisions
ahead of the remote tracking branch. This is a state you will obtain after committing in
the local tracking branch.
The [behind 2] message indicates you that your local tracking branch is behind
the remote tracking branch. Your local tracking branch misses two revisions available
in remote tracking branch. You are in this state when some member of your team
pushes his or her commits to the shared repository and you download them to your re-
pository with the $ git fetch command.
The final message, [ahead 2, behind 1] means that the local tracking
branch and the remote tracking branch have diverged. The local tracking branch con-
tains two revisions that are not in the remote tracking branch and at the same time it
has missed one revision contained in the remote tracking branch. You obtained this
state after the $ git commit and $ git fetch commands, assuming that
someone pushed to the shared repository.
Accessing remote branches
Remember that the $ git status -sb and $ git branch -a -vv com-
mands only work with your local branches. These are: ordinary local branches, local
tracking branches, and remote tracking branches. The commands $ git status
and $ git branch do not access the remote branches in the remote repository. The
remote branches are only transferred to your repository during $ git fetch . There-
fore, if you want to inspect the remote end you will need to run $ git fetch fol-
lowed by $ git status -sb or $ git branch -a -vv . But no matter how
fast you are, the result of $ git status -sb or $ git branch -a -vv can
be outdated in the sense that someone could have pushed to the remote repository after
Search WWH ::




Custom Search