Information Technology Reference
In-Depth Information
This means that the local tracking branch master misses two revisions that are in-
cluded in the remote tracking branch origin/master .
The case of diverged branches is shown in Figure 10-23 . The command $ git
fetch executed in marks-repo shown in Figure 10-22 produces the result shown
in Figure 10-23 . This time the output of $ git status -sb would be:
## master...origin/master [ahead 2, behind 3]
Therefore, the local tracking branch is two revisions ahead and three revisions be-
hind the remote tracking branch.
Rebasing the local tracking branch onto the remote
tracking branch
Remote tracking branches, such as origin/master , are local branches. They can be
used in the same manner as ordinary local branches. Therefore, to keep a history linear
we can use the $ git rebase command as discussed in Recipe 7-1. The command
$ git rebase origin/master master issued in marks-repo from Figure
10-23 will produce the effect shown in Figure 10-24 .
If you set tracking for the master branch then the command $ git rebase
origin/master master can be simplified to:
$ git rebase
It performs the rebasing of your current local tracking branch on top of its remote
tracking branch.
You also can use the $ git pull command to achieve the same result. By de-
fault the command $ git pull is executed as $ git fetch followed by $ git
merge . Although changing this behavior you could use the -r flag or configuration
settings. The command $ git pull -r is equivalent to $ git fetch followed
by $ git rebase .
Remember that the $ git fetch command updates your local database and re-
mote tracking branches. It never influences your local tracking branches or your ordin-
ary local branches. Therefore, you can safely run $ git fetch at any time. It will
never cause you any trouble.
Search WWH ::




Custom Search