]> rtime.felk.cvut.cz Git - git.git/blob - Documentation/git-remote.txt
Merge branch 'mg/notes-dry-run'
[git.git] / Documentation / git-remote.txt
1 git-remote(1)
2 ============
3
4 NAME
5 ----
6 git-remote - manage set of tracked repositories
7
8
9 SYNOPSIS
10 --------
11 [verse]
12 'git remote' [-v | --verbose]
13 'git remote add' [-t <branch>] [-m <master>] [-f] [--tags|--no-tags] [--mirror] <name> <url>
14 'git remote rename' <old> <new>
15 'git remote rm' <name>
16 'git remote set-head' <name> (-a | -d | <branch>)
17 'git remote set-url' [--push] <name> <newurl> [<oldurl>]
18 'git remote set-url --add' [--push] <name> <newurl>
19 'git remote set-url --delete' [--push] <name> <url>
20 'git remote' [-v | --verbose] 'show' [-n] <name>
21 'git remote prune' [-n | --dry-run] <name>
22 'git remote' [-v | --verbose] 'update' [-p | --prune] [group | remote]...
23
24 DESCRIPTION
25 -----------
26
27 Manage the set of repositories ("remotes") whose branches you track.
28
29
30 OPTIONS
31 -------
32
33 -v::
34 --verbose::
35         Be a little more verbose and show remote url after name.
36         NOTE: This must be placed between `remote` and `subcommand`.
37
38
39 COMMANDS
40 --------
41
42 With no arguments, shows a list of existing remotes.  Several
43 subcommands are available to perform operations on the remotes.
44
45 'add'::
46
47 Adds a remote named <name> for the repository at
48 <url>.  The command `git fetch <name>` can then be used to create and
49 update remote-tracking branches <name>/<branch>.
50 +
51 With `-f` option, `git fetch <name>` is run immediately after
52 the remote information is set up.
53 +
54 With `--tags` option, `git fetch <name>` imports every tag from the
55 remote repository.
56 +
57 With `--no-tags` option, `git fetch <name>` does not import tags from
58 the remote repository.
59 +
60 With `-t <branch>` option, instead of the default glob
61 refspec for the remote to track all branches under
62 `$GIT_DIR/remotes/<name>/`, a refspec to track only `<branch>`
63 is created.  You can give more than one `-t <branch>` to track
64 multiple branches without grabbing all branches.
65 +
66 With `-m <master>` option, `$GIT_DIR/remotes/<name>/HEAD` is set
67 up to point at remote's `<master>` branch. See also the set-head command.
68 +
69 In mirror mode, enabled with `\--mirror`, the refs will not be stored
70 in the 'refs/remotes/' namespace, but in 'refs/heads/'.  This option
71 only makes sense in bare repositories.  If a remote uses mirror
72 mode, furthermore, `git push` will always behave as if `\--mirror`
73 was passed.
74
75 'rename'::
76
77 Rename the remote named <old> to <new>. All remote tracking branches and
78 configuration settings for the remote are updated.
79 +
80 In case <old> and <new> are the same, and <old> is a file under
81 `$GIT_DIR/remotes` or `$GIT_DIR/branches`, the remote is converted to
82 the configuration file format.
83
84 'rm'::
85
86 Remove the remote named <name>. All remote tracking branches and
87 configuration settings for the remote are removed.
88
89 'set-head'::
90
91 Sets or deletes the default branch (`$GIT_DIR/remotes/<name>/HEAD`) for
92 the named remote. Having a default branch for a remote is not required,
93 but allows the name of the remote to be specified in lieu of a specific
94 branch. For example, if the default branch for `origin` is set to
95 `master`, then `origin` may be specified wherever you would normally
96 specify `origin/master`.
97 +
98 With `-d`, `$GIT_DIR/remotes/<name>/HEAD` is deleted.
99 +
100 With `-a`, the remote is queried to determine its `HEAD`, then
101 `$GIT_DIR/remotes/<name>/HEAD` is set to the same branch. e.g., if the remote
102 `HEAD` is pointed at `next`, "`git remote set-head origin -a`" will set
103 `$GIT_DIR/refs/remotes/origin/HEAD` to `refs/remotes/origin/next`. This will
104 only work if `refs/remotes/origin/next` already exists; if not it must be
105 fetched first.
106 +
107 Use `<branch>` to set `$GIT_DIR/remotes/<name>/HEAD` explicitly. e.g., "git
108 remote set-head origin master" will set `$GIT_DIR/refs/remotes/origin/HEAD` to
109 `refs/remotes/origin/master`. This will only work if
110 `refs/remotes/origin/master` already exists; if not it must be fetched first.
111 +
112
113 'set-url'::
114
115 Changes URL remote points to. Sets first URL remote points to matching
116 regex <oldurl> (first URL if no <oldurl> is given) to <newurl>. If
117 <oldurl> doesn't match any URL, error occurs and nothing is changed.
118 +
119 With '--push', push URLs are manipulated instead of fetch URLs.
120 +
121 With '--add', instead of changing some URL, new URL is added.
122 +
123 With '--delete', instead of changing some URL, all URLs matching
124 regex <url> are deleted. Trying to delete all non-push URLs is an
125 error.
126
127 'show'::
128
129 Gives some information about the remote <name>.
130 +
131 With `-n` option, the remote heads are not queried first with
132 `git ls-remote <name>`; cached information is used instead.
133
134 'prune'::
135
136 Deletes all stale tracking branches under <name>.
137 These stale branches have already been removed from the remote repository
138 referenced by <name>, but are still locally available in
139 "remotes/<name>".
140 +
141 With `--dry-run` option, report what branches will be pruned, but do not
142 actually prune them.
143
144 'update'::
145
146 Fetch updates for a named set of remotes in the repository as defined by
147 remotes.<group>.  If a named group is not specified on the command line,
148 the configuration parameter remotes.default will be used; if
149 remotes.default is not defined, all remotes which do not have the
150 configuration parameter remote.<name>.skipDefaultUpdate set to true will
151 be updated.  (See linkgit:git-config[1]).
152 +
153 With `--prune` option, prune all the remotes that are updated.
154
155
156 DISCUSSION
157 ----------
158
159 The remote configuration is achieved using the `remote.origin.url` and
160 `remote.origin.fetch` configuration variables.  (See
161 linkgit:git-config[1]).
162
163 Examples
164 --------
165
166 * Add a new remote, fetch, and check out a branch from it
167 +
168 ------------
169 $ git remote
170 origin
171 $ git branch -r
172 origin/master
173 $ git remote add linux-nfs git://linux-nfs.org/pub/linux/nfs-2.6.git
174 $ git remote
175 linux-nfs
176 origin
177 $ git fetch
178 * refs/remotes/linux-nfs/master: storing branch 'master' ...
179   commit: bf81b46
180 $ git branch -r
181 origin/master
182 linux-nfs/master
183 $ git checkout -b nfs linux-nfs/master
184 ...
185 ------------
186
187 * Imitate 'git clone' but track only selected branches
188 +
189 ------------
190 $ mkdir project.git
191 $ cd project.git
192 $ git init
193 $ git remote add -f -t master -m master origin git://example.com/git.git/
194 $ git merge origin
195 ------------
196
197
198 SEE ALSO
199 --------
200 linkgit:git-fetch[1]
201 linkgit:git-branch[1]
202 linkgit:git-config[1]
203
204 Author
205 ------
206 Written by Junio Hamano
207
208
209 Documentation
210 --------------
211 Documentation by J. Bruce Fields and the git-list <git@vger.kernel.org>.
212
213
214 GIT
215 ---
216 Part of the linkgit:git[1] suite