Information Technology Reference
In-Depth Information
Now we turn an ordinary local branch master into a local tracking branch for the
remote tracking origin/master branch. This is done with:
$ git branch --set-upstream-to=origin/master
After this, $ git branch -a -vv prints:
* master
60478cc [origin/master] Bump
version to 0.3.1
remotes/origin/master 60478cc Bump version to 0.3.1
Thanks to [origin/master] in the first line we know that master is a local
tracking branch for the remote tracking branch origin/master .
The command $ branch --set-upstream-to=origin/master creates
the following entry in .git/config file:
[branch "master"]
remote = origin
merge = refs/heads/master
This says that your local master branch is set to track the remote branch stored in
refs/heads/master in the repository pointed by origin URL. It is easier to un-
derstand the meaning of the above command with the example using a different name
for the local and remote branches. Suppose that your local repository contains an ordin-
ary local branch named foo . You want the foo branch to track the bar branch in the
remote repository. If you issue the command:
$ git branch --set-upstream-to=origin/bar foo
then the following configuration entry will be created:
[branch "foo"]
remote = origin
merge = refs/heads/bar
The remote repository pointed by origin contains a file .git/refs/heads/
bar . This is the remote branch bar . The local repository contains .git/refs/re-
motes/origin/bar and .git/refs/heads/foo . The first file .git/refs/
Search WWH ::




Custom Search