Merge branch 'ab/merge-file-prefix' into maint
[git/gitweb.git] / Documentation / git-remote.txt
bloba77607b852c1f9cbcea7b9d1a359e5c467933aa0
1 git-remote(1)
2 ============
4 NAME
5 ----
6 git-remote - Manage set of tracked repositories
9 SYNOPSIS
10 --------
11 [verse]
12 'git remote' [-v | --verbose]
13 'git remote add' [-t <branch>] [-m <master>] [-f] [--[no-]tags] [--mirror=<fetch|push>] <name> <url>
14 'git remote rename' <old> <new>
15 'git remote remove' <name>
16 'git remote set-head' <name> (-a | --auto | -d | --delete | <branch>)
17 'git remote set-branches' [--add] <name> <branch>...
18 'git remote set-url' [--push] <name> <newurl> [<oldurl>]
19 'git remote set-url --add' [--push] <name> <newurl>
20 'git remote set-url --delete' [--push] <name> <url>
21 'git remote' [-v | --verbose] 'show' [-n] <name>...
22 'git remote prune' [-n | --dry-run] <name>...
23 'git remote' [-v | --verbose] 'update' [-p | --prune] [(<group> | <remote>)...]
25 DESCRIPTION
26 -----------
28 Manage the set of repositories ("remotes") whose branches you track.
31 OPTIONS
32 -------
34 -v::
35 --verbose::
36         Be a little more verbose and show remote url after name.
37         NOTE: This must be placed between `remote` and `subcommand`.
40 COMMANDS
41 --------
43 With no arguments, shows a list of existing remotes.  Several
44 subcommands are available to perform operations on the remotes.
46 'add'::
48 Adds a remote named <name> for the repository at
49 <url>.  The command `git fetch <name>` can then be used to create and
50 update remote-tracking branches <name>/<branch>.
52 With `-f` option, `git fetch <name>` is run immediately after
53 the remote information is set up.
55 With `--tags` option, `git fetch <name>` imports every tag from the
56 remote repository.
58 With `--no-tags` option, `git fetch <name>` does not import tags from
59 the remote repository.
61 With `-t <branch>` option, instead of the default glob
62 refspec for the remote to track all branches under
63 the `refs/remotes/<name>/` namespace, a refspec to track only `<branch>`
64 is created.  You can give more than one `-t <branch>` to track
65 multiple branches without grabbing all branches.
67 With `-m <master>` option, a symbolic-ref `refs/remotes/<name>/HEAD` is set
68 up to point at remote's `<master>` branch. See also the set-head command.
70 When a fetch mirror is created with `--mirror=fetch`, the refs will not
71 be stored in the 'refs/remotes/' namespace, but rather everything in
72 'refs/' on the remote will be directly mirrored into 'refs/' in the
73 local repository. This option only makes sense in bare repositories,
74 because a fetch would overwrite any local commits.
76 When a push mirror is created with `--mirror=push`, then `git push`
77 will always behave as if `--mirror` was passed.
79 'rename'::
81 Rename the remote named <old> to <new>. All remote-tracking branches and
82 configuration settings for the remote are updated.
84 In case <old> and <new> are the same, and <old> is a file under
85 `$GIT_DIR/remotes` or `$GIT_DIR/branches`, the remote is converted to
86 the configuration file format.
88 'remove'::
89 'rm'::
91 Remove the remote named <name>. All remote-tracking branches and
92 configuration settings for the remote are removed.
94 'set-head'::
96 Sets or deletes the default branch (i.e. the target of the
97 symbolic-ref `refs/remotes/<name>/HEAD`) for
98 the named remote. Having a default branch for a remote is not required,
99 but allows the name of the remote to be specified in lieu of a specific
100 branch. For example, if the default branch for `origin` is set to
101 `master`, then `origin` may be specified wherever you would normally
102 specify `origin/master`.
104 With `-d` or `--delete`, the symbolic ref `refs/remotes/<name>/HEAD` is deleted.
106 With `-a` or `--auto`, the remote is queried to determine its `HEAD`, then the
107 symbolic-ref `refs/remotes/<name>/HEAD` is set to the same branch. e.g., if the remote
108 `HEAD` is pointed at `next`, "`git remote set-head origin -a`" will set
109 the symbolic-ref `refs/remotes/origin/HEAD` to `refs/remotes/origin/next`. This will
110 only work if `refs/remotes/origin/next` already exists; if not it must be
111 fetched first.
113 Use `<branch>` to set the symbolic-ref `refs/remotes/<name>/HEAD` explicitly. e.g., "git
114 remote set-head origin master" will set the symbolic-ref `refs/remotes/origin/HEAD` to
115 `refs/remotes/origin/master`. This will only work if
116 `refs/remotes/origin/master` already exists; if not it must be fetched first.
119 'set-branches'::
121 Changes the list of branches tracked by the named remote.
122 This can be used to track a subset of the available remote branches
123 after the initial setup for a remote.
125 The named branches will be interpreted as if specified with the
126 `-t` option on the 'git remote add' command line.
128 With `--add`, instead of replacing the list of currently tracked
129 branches, adds to that list.
131 'set-url'::
133 Changes URLs for the remote. Sets first URL for remote <name> that matches
134 regex <oldurl> (first URL if no <oldurl> is given) to <newurl>. If
135 <oldurl> doesn't match any URL, an error occurs and nothing is changed.
137 With '--push', push URLs are manipulated instead of fetch URLs.
139 With '--add', instead of changing existing URLs, new URL is added.
141 With '--delete', instead of changing existing URLs, all URLs matching
142 regex <url> are deleted for remote <name>.  Trying to delete all
143 non-push URLs is an error.
145 Note that the push URL and the fetch URL, even though they can
146 be set differently, must still refer to the same place.  What you
147 pushed to the push URL should be what you would see if you
148 immediately fetched from the fetch URL.  If you are trying to
149 fetch from one place (e.g. your upstream) and push to another (e.g.
150 your publishing repository), use two separate remotes.
153 'show'::
155 Gives some information about the remote <name>.
157 With `-n` option, the remote heads are not queried first with
158 `git ls-remote <name>`; cached information is used instead.
160 'prune'::
162 Deletes all stale remote-tracking branches under <name>.
163 These stale branches have already been removed from the remote repository
164 referenced by <name>, but are still locally available in
165 "remotes/<name>".
167 With `--dry-run` option, report what branches will be pruned, but do not
168 actually prune them.
170 'update'::
172 Fetch updates for a named set of remotes in the repository as defined by
173 remotes.<group>.  If a named group is not specified on the command line,
174 the configuration parameter remotes.default will be used; if
175 remotes.default is not defined, all remotes which do not have the
176 configuration parameter remote.<name>.skipDefaultUpdate set to true will
177 be updated.  (See linkgit:git-config[1]).
179 With `--prune` option, prune all the remotes that are updated.
182 DISCUSSION
183 ----------
185 The remote configuration is achieved using the `remote.origin.url` and
186 `remote.origin.fetch` configuration variables.  (See
187 linkgit:git-config[1]).
189 Examples
190 --------
192 * Add a new remote, fetch, and check out a branch from it
194 ------------
195 $ git remote
196 origin
197 $ git branch -r
198   origin/HEAD -> origin/master
199   origin/master
200 $ git remote add staging git://git.kernel.org/.../gregkh/staging.git
201 $ git remote
202 origin
203 staging
204 $ git fetch staging
206 From git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging
207  * [new branch]      master     -> staging/master
208  * [new branch]      staging-linus -> staging/staging-linus
209  * [new branch]      staging-next -> staging/staging-next
210 $ git branch -r
211   origin/HEAD -> origin/master
212   origin/master
213   staging/master
214   staging/staging-linus
215   staging/staging-next
216 $ git checkout -b staging staging/master
218 ------------
220 * Imitate 'git clone' but track only selected branches
222 ------------
223 $ mkdir project.git
224 $ cd project.git
225 $ git init
226 $ git remote add -f -t master -m master origin git://example.com/git.git/
227 $ git merge origin
228 ------------
231 SEE ALSO
232 --------
233 linkgit:git-fetch[1]
234 linkgit:git-branch[1]
235 linkgit:git-config[1]
239 Part of the linkgit:git[1] suite