Information Technology Reference
In-Depth Information
is equivalent to:
$ git fetch --no-tags
https://github.com/creationix/
js-git.git
master:refs/remotes/origin/master
Remotes can be listed with the
$ git remote
command. By default this com-
mand prints defined aliases. The additional parameter
-v
turns on the verbose output.
The command
$ git remote -v
prints the names and URL for all aliases. The re-
motes can be removed with the
$ git remote rm [alias]
command.
All the remotes are stored in the
.git/config
file. When you execute:
$ git
remote add foo
https://example.comnet/bar.git
, git adds the follow-
ing entry in the
.git/config
file:
[remote "foo"]
fetch = +refs/heads/*:refs/remotes/foo/*
The line:
stores the URL. The second line:
fetch = +refs/heads/*:refs/remotes/foo/*
defines a so-called
refspec
. Refspec specifies the way the remote branches (i.e., the
branches in the remote repository) are mapped to the remote tracking branches (i.e.,
local branches stored in the
refs/remotes/foo
directory). The remote repository
contains branches in its
.git/refs/heads
directory. We want to copy them in such
a way that they do not collide with our ordinary local branches stored locally in
.git/
refs/heads
. Therefore we place the remote tracking branches into a separate direct-
ory named
.git/refs/remotes/foo
. As long as the aliases used to name the re-
motes are unique we can be sure that the branches from different remotes will not col-
lide with each other or with our local branches.
You can treat:
fetch = +refs/heads/*:refs/remotes/foo/*